@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a28;
    --bg-card-hover: #222236;
    --bg-glass: rgba(255, 255, 255, 0.04);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f0ece4;
    --text-secondary: #9a9aad;
    --text-muted: #5a5a70;
    --accent: #c8a461;
    --accent-glow: rgba(200, 164, 97, 0.15);
    --accent-dim: #6b5a36;
    --tag-bg: rgba(200, 164, 97, 0.12);
    --price-color: #e8d5a8;
    --off-menu: #ff6b6b;
    --note-bg: rgba(200, 164, 97, 0.08);
    --note-border: rgba(200, 164, 97, 0.2);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 10px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    overscroll-behavior: none;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 12px 16px 0;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.header-title .logo {
    font-size: 1.3rem;
}

.header-title h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, var(--accent), #e8d5a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-title .count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Search Box */
.search-container {
    position: relative;
    margin-bottom: 12px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s;
}

.search-input {
    width: 100%;
    padding: 12px 44px 12px 42px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all 0.25s ease;
}

.search-input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), inset 0 0 0 1px rgba(200, 164, 97, 0.15);
}

.search-input:focus~.search-icon {
    color: var(--accent);
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 0.85rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.search-clear.visible {
    display: flex;
}

.search-clear:active {
    background: rgba(255, 255, 255, 0.15);
}

/* Category Tabs */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding-bottom: 12px;
}

.tab {
    padding: 7px 0;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex: 1 1 calc(16.666% - 5px);
    min-width: calc(16.666% - 5px);
    max-width: calc(20% - 5px);
    text-align: center;
}

.tab:active {
    transform: scale(0.95);
}

.tab.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    font-weight: 700;
}

/* Drink List */
.drink-list {
    padding: 8px 16px 100px;
}

.drink-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.drink-card:active {
    transform: scale(0.99);
}

.drink-card.expanded {
    border-color: rgba(200, 164, 97, 0.25);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.drink-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    gap: 10px;
    user-select: none;
}

.drink-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

.drink-name mark {
    background: var(--accent-glow);
    color: var(--accent);
    border-radius: 2px;
    padding: 0 1px;
}

.off-menu-badge {
    font-size: 0.6rem;
    color: var(--off-menu);
    border: 1px solid var(--off-menu);
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.8;
}

.drink-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--price-color);
    white-space: nowrap;
}

.drink-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.drink-card.expanded .drink-chevron {
    transform: rotate(90deg);
}

/* Recipe Detail */
.drink-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.drink-card.expanded .drink-detail {
    max-height: 600px;
}

.drink-detail-inner {
    padding: 0 16px 16px;
}

.detail-section {
    margin-bottom: 10px;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
    font-weight: 500;
}

.detail-glass {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--tag-bg);
    padding: 4px 10px;
    border-radius: 6px;
}

.detail-price-note {
    font-size: 0.78rem;
    color: var(--accent);
    opacity: 0.8;
    margin-top: 2px;
}

.recipe-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.7;
    font-weight: 300;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    padding: 12px;
    border-left: 3px solid var(--accent-dim);
}

.note-text {
    font-size: 0.8rem;
    color: var(--accent);
    background: var(--note-bg);
    border: 1px solid var(--note-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    line-height: 1.5;
    font-weight: 400;
}

.note-text::before {
    content: '💡 ';
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
    font-weight: 300;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.drink-card {
    animation: fadeIn 0.25s ease both;
}

/* Navigation */
.nav-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-glass);
    margin: 0 -16px;
    padding: 0 16px;
}

.nav-tab {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Slip Calculator */
.slip-container {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.slip-input-section {
    margin-bottom: 20px;
}

.slip-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: block;
}

.slip-textarea {
    width: 100%;
    min-height: 200px;
    padding: 14px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.slip-textarea::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.slip-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.slip-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.slip-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--bg-primary);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.slip-btn:active {
    transform: scale(0.97);
}

.slip-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.slip-btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    font-weight: 500;
    flex: 0 0 auto;
}

.slip-btn-copy {
    width: 100%;
    margin-top: 12px;
    background: var(--bg-card);
    color: var(--accent);
    border: 1px solid var(--accent-dim);
    font-weight: 500;
    font-size: 0.9rem;
}

.slip-result-section {
    margin-top: 20px;
}

.slip-result {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 20px;
    font-size: 0.92rem;
    line-height: 2;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    border-left: 3px solid var(--accent);
}

.slip-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.slip-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.slip-error {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: var(--radius-sm);
    color: var(--off-menu);
    font-size: 0.85rem;
}

/* Slip Table */
.slip-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--border-glass);
}

.slip-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    white-space: nowrap;
}

.slip-table th {
    background: var(--bg-card);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    padding: 8px 6px;
    text-align: right;
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
}

.slip-table th:first-child,
.slip-table td:first-child {
    text-align: center;
}

.slip-table td {
    padding: 6px 6px;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.slip-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.slip-table .mixed-row {
    background: var(--accent-glow);
}

.slip-table .mixed-row td {
    color: var(--accent);
}

.slip-table tfoot .total-row {
    background: var(--bg-card);
    border-top: 2px solid var(--accent-dim);
}

.slip-table tfoot .total-row td {
    font-weight: 700;
    color: var(--text-primary);
    padding: 10px 6px;
}

/* Viewport Optimizations */
@supports (padding: env(safe-area-inset-bottom)) {
    .drink-list {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
}