* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 100%;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.view {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.view.hidden {
    display: none;
}

.collections-header,
.things-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.collections-header h2,
.things-header h2 {
    font-size: 1.3rem;
    color: #333;
    flex: 1;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ff4757;
    color: white;
}

.btn-danger:hover {
    background: #ff3838;
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.collections-list {
    display: grid;
    gap: 10px;
}

.collection-item {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    cursor: pointer;
    touch-action: manipulation;
}

.collection-item:hover {
    border-color: #667eea;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.collection-item-content {
    flex: 1;
}

.collection-item-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
}

.collection-item-actions {
    display: flex;
    gap: 10px;
}

.things-list {
    display: grid;
    gap: 12px;
}

.thing-item {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s ease;
}

.thing-row-first {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.count-btn-minus {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: #e9ecef;
    color: #666;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.count-btn-minus:active {
    background: #dee2e6;
    transform: scale(0.95);
}

.count-btn-plus {
    flex: 1;
    min-height: 72px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 12px;
    gap: 4px;
}

.count-btn-plus:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.plus-btn-label {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.plus-btn-symbol {
    font-size: 1.8rem;
    font-weight: bold;
    line-height: 1;
}

.thing-row-second {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.thing-row-second .btn-small {
    flex-shrink: 0;
}

.count-value {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    min-width: 35px;
    text-align: center;
    flex-shrink: 0;
}

.progress-bar {
    flex: 1;
    min-width: 100px;
    height: 20px;
    background: #adb5bd;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    z-index: 1;
}

.progress-bar::after {
    content: attr(data-percentage);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #666;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: #333;
}

.modal input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 12px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.modal input:last-of-type {
    margin-bottom: 20px;
}

.modal input:focus {
    outline: none;
    border-color: #667eea;
}

.modal input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.modal input[type="number"]::-webkit-inner-spin-button,
.modal input[type="number"]::-webkit-outer-spin-button {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* iPhone/mobile optimizations */
@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    .view {
        padding: 12px;
        border-radius: 10px;
    }

    header h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    .collections-header,
    .things-header {
        margin-bottom: 12px;
    }

    .collections-header h2,
    .things-header h2 {
        font-size: 1.1rem;
    }

    .collections-list {
        gap: 8px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .count-btn-plus {
        min-height: 80px;
    }

    .plus-btn-label {
        font-size: 1.1rem;
    }

    .plus-btn-symbol {
        font-size: 2rem;
    }

    .count-btn-minus {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }

    .count-value {
        font-size: 1.1rem;
        min-width: 40px;
    }

    .progress-bar {
        height: 22px;
    }

    .progress-bar::after {
        font-size: 0.75rem;
    }
}

/* Prevent text selection on buttons for better mobile UX */
.count-btn-plus,
.count-btn-minus,
.btn {
    user-select: none;
    -webkit-user-select: none;
}

