/* =============================================================================
   Coffee Review — CoE evaluation app
   Theme: Specialty Lab — clean, neutral, instrument-grade
   ========================================================================== */

:root {
    /* Surfaces */
    --bg-page: #f6f7f8;
    --bg-card: #ffffff;
    --bg-soft: #f0f2f4;
    --bg-elevated: #ffffff;
    --bg-muted: #eef0f2;
    --bg-muted-hover: #e3e6ea;

    /* Text */
    --text-primary: #111418;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;

    /* Borders */
    --border: #e5e7eb;
    --border-strong: #d1d5db;

    /* Accent */
    --accent: #0e4d4d;
    --accent-hover: #073a3a;
    --accent-soft: #d3e3e3;
    --accent-tint: rgba(14, 77, 77, 0.10);

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(17, 20, 24, 0.05);
    --shadow-md: 0 2px 8px rgba(17, 20, 24, 0.06);
    --shadow-lg: 0 8px 24px rgba(17, 20, 24, 0.10);

    /* Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.4rem;
    --radius-lg: 0.55rem;

    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    /* Medal flat palettes */
    --t1-bg: #6b7280; --t1-fg: #ffffff;
    --t2-bg: #78716c; --t2-fg: #ffffff;
    --t3-bg: #a86b3c; --t3-fg: #ffffff;
    --t4-bg: #94a3b8; --t4-fg: #111418;
    --t5-bg: #c08c2a; --t5-fg: #111418;
    --t6-bg: #3b7a8c; --t6-fg: #ffffff;
    --t7-bg: #5d4ba6; --t7-fg: #ffffff;

    /* Tabbar height — reserved at bottom of page so content isn't covered */
    --tabbar-height: 64px;
}

/* ───── Base ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
                 "Noto Sans TC", "Helvetica Neue", sans-serif;
    line-height: 1.55;
    padding-top: calc(env(safe-area-inset-top, 0px) + 0.85rem);
    padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + 1rem);
}

.container { max-width: 820px; }

/* ───── Bottom tab bar ─────────────────────────────────────────────────── */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(17, 20, 24, 0.04);
    z-index: 1000;
}
.tabbar-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 500;
    transition: color 0.15s;
}
.tabbar-btn .bi { font-size: 1.35rem; line-height: 1; }
.tabbar-btn:hover { color: var(--accent); }
.tabbar-btn.active { color: var(--accent); }
.tabbar-btn.active .bi { transform: translateY(-1px); }

/* ───── Cards ──────────────────────────────────────────────────────────── */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    overflow: hidden;
}
.card-body { padding: 1.1rem 1.2rem; }
.card-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-title .bi { color: var(--accent); }
.card-title .ms-auto { margin-left: auto; }

button.card-title {
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    padding: 0;
}
.card-title-collapsible {
    cursor: pointer;
    user-select: none;
    transition: margin-bottom 0.2s ease;
}
.card-title-collapsible.collapsed { margin-bottom: 0; }
.card-title-collapsible:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
    border-radius: var(--radius-sm);
}
.card-title-collapsible .card-toggle-chevron {
    margin-left: auto;
    color: var(--text-muted) !important;
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}
.card-title-collapsible:not(.collapsed) .card-toggle-chevron {
    transform: rotate(180deg);
}

/* ───── Forms ──────────────────────────────────────────────────────────── */
.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    font-size: 0.88rem;
}
.form-control, .form-select {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
    padding: 0.4rem 0.7rem;
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-elevated);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-tint);
    color: var(--text-primary);
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--accent-tint); }
.form-check-label { color: var(--text-secondary); font-size: 0.88rem; }

/* ───── Buttons ────────────────────────────────────────────────────────── */
.btn { border-radius: var(--radius-sm); font-weight: 500; font-size: 0.9rem; transition: all 0.15s ease; }
.btn-primary { background-color: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--accent-hover); border-color: var(--accent-hover); }
.btn-info { background-color: #475569; border-color: #475569; color: #fff; }
.btn-info:hover { background-color: #334155; border-color: #334155; color: #fff; }
.btn-success { background-color: #3a7a5a; border-color: #3a7a5a; }
.btn-success:hover { background-color: #2e6448; border-color: #2e6448; }
.btn-outline-secondary { color: var(--text-secondary); border-color: var(--border-strong); }
.btn-outline-secondary:hover { background-color: var(--bg-soft); color: var(--text-primary); border-color: var(--border-strong); }
.btn-outline-danger:hover { background-color: #d9534f; border-color: #d9534f; }

/* ───── New record mode picker ─────────────────────────────────────────── */
.new-mode-picker-card .new-mode-picker-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 1rem;
}
.new-mode-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.85rem;
}
.new-mode-picker-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 1.4rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    text-align: center;
    transition: border-color 0.15s, background-color 0.15s, transform 0.1s;
}
.new-mode-picker-btn:hover {
    border-color: var(--accent);
    background-color: var(--accent-tint);
    color: var(--text-primary);
}
.new-mode-picker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--accent-tint);
    color: var(--accent);
    font-size: 1.4rem;
}
.new-mode-picker-label {
    font-size: 1.15rem;
    font-weight: 700;
}
.new-mode-picker-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
}

/* ───── Shop picker (select + add button) ──────────────────────────────── */
.shop-picker {
    display: flex;
    gap: 0.4rem;
}
.shop-picker .form-select { flex: 1; }

/* ───── Filter bar (records list) ──────────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    align-items: center;
}
.filter-chip-row {
    display: flex;
    gap: 0.35rem;
}
.filter-chip {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
}
.filter-chip:hover { color: var(--accent); border-color: var(--accent); }
.filter-chip.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.filter-shop-wrap {
    margin-left: auto;
    min-width: 0;
    flex-shrink: 1;
}
.filter-shop-wrap .form-select { min-width: 10rem; }

/* ───── Records list ───────────────────────────────────────────────────── */
.records-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.record-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.record-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}
.record-card:active { transform: scale(0.997); }

.record-card-medal {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-muted);
    color: var(--text-dim);
}
.record-card-medal.t-trash      { background: var(--t1-bg); color: var(--t1-fg); }
.record-card-medal.t-commercial { background: var(--t2-bg); color: var(--t2-fg); }
.record-card-medal.t-common     { background: var(--t3-bg); color: var(--t3-fg); }
.record-card-medal.t-like       { background: var(--t4-bg); color: var(--t4-fg); }
.record-card-medal.t-recommend  { background: var(--t5-bg); color: var(--t5-fg); }
.record-card-medal.t-amazing    { background: var(--t6-bg); color: var(--t6-fg); }
.record-card-medal.t-godly      { background: var(--t7-bg); color: var(--t7-fg); }
.record-card-medal-text {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}
.record-card-medal-score {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.1;
    margin-top: 0.12rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.92;
}

.record-card-body {
    flex: 1;
    min-width: 0;
}
.record-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}
.record-card-type-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    line-height: 1.3;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.record-card-type-badge.type-cupping {
    background: var(--accent-tint);
    color: var(--accent);
}
.record-card-type-badge.type-tasting {
    background: rgba(192, 140, 42, 0.15);
    color: #876615;
}
.record-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.record-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}
.record-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.record-card-chevron {
    color: var(--text-dim);
    font-size: 1rem;
    flex-shrink: 0;
}

/* ───── Empty state ────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
}
.empty-state .bi {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
}
.empty-state p {
    margin: 0 0 0.85rem;
    font-size: 0.95rem;
}
.empty-state.error {
    border-color: #f5c2c0;
    background: #fef3f3;
    color: #842029;
}
.empty-state.error .bi { color: #b03a36; }
.empty-state.small {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    text-align: left;
}
.empty-state.small .bi {
    font-size: 1rem;
    display: inline;
    margin-right: 0.35rem;
    margin-bottom: 0;
}

/* ───── CoE Total Card — Flat medal style ──────────────────────────────── */
.coe-card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
}

.medal-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55rem 0.7rem;
    margin-bottom: 1.5rem;
}

.medal-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.32rem;
    min-width: 64px;
}

.tier-medal {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    padding: 0;
    background-color: var(--bg-muted);
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease,
                transform 0.15s ease, box-shadow 0.15s ease;
}
.tier-medal:hover { background-color: var(--bg-muted-hover); }
.tier-medal:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
}
.tier-medal.selected {
    background-color: var(--medal-bg, var(--accent));
    color: var(--medal-fg, #fff);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}
.tier-medal .medal-text {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    display: block;
}

.medal-cell .medal-range-label {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.medal-cell.selected .medal-range-label {
    color: var(--text-primary);
    font-weight: 700;
}

.tier-medal.t-trash      { --medal-bg: var(--t1-bg); --medal-fg: var(--t1-fg); }
.tier-medal.t-commercial { --medal-bg: var(--t2-bg); --medal-fg: var(--t2-fg); }
.tier-medal.t-common     { --medal-bg: var(--t3-bg); --medal-fg: var(--t3-fg); }
.tier-medal.t-like       { --medal-bg: var(--t4-bg); --medal-fg: var(--t4-fg); }
.tier-medal.t-recommend  { --medal-bg: var(--t5-bg); --medal-fg: var(--t5-fg); }
.tier-medal.t-amazing    { --medal-bg: var(--t6-bg); --medal-fg: var(--t6-fg); }
.tier-medal.t-godly      { --medal-bg: var(--t7-bg); --medal-fg: var(--t7-fg); }

.score-chip-row {
    --tier-color: var(--accent);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 0.85rem;
    background-color: var(--bg-page);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}
.score-chip {
    display: inline-block;
    min-width: 3rem;
    padding: 0.4rem 0.85rem;
    text-align: center;
    border-radius: 999px;
    border: 1.5px solid var(--border-strong);
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    transition: all 0.12s ease;
    font: inherit;
    line-height: 1;
}
.score-chip:hover { border-color: var(--tier-color); color: var(--tier-color); }
.score-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-tint); }
.score-chip.selected {
    background-color: var(--tier-color);
    border-color: var(--tier-color);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.coe-total-block {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    padding-top: 0.3rem;
}
.coe-total-display {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.coe-total-of { font-size: 0.85rem; color: var(--text-dim); font-weight: 500; }
.coe-total-tier-badge {
    font-size: 1rem;
    font-weight: 700;
    padding-left: 0.5rem;
    letter-spacing: 0.02em;
}
.coe-total-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-basis: 100%;
    margin-top: 0.35rem;
}

/* ───── Accordion ──────────────────────────────────────────────────────── */
.accordion { background: transparent; margin-bottom: 0; }
.accordion-flush > .accordion-item {
    background-color: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 0;
}
.accordion-flush > .accordion-item:last-of-type { border-bottom: none; }
.accordion-flush > .accordion-item:first-of-type { border-top: 1px solid var(--border); }
.accordion-flush > .accordion-item .accordion-button,
.accordion-flush > .accordion-item .accordion-button:not(.collapsed) {
    display: flex;
    align-items: center;
    width: 100%;
    background-color: transparent;
    color: var(--text-primary);
    box-shadow: none;
    padding: 0.7rem 0.4rem;
    font-weight: 600;
    gap: 0.55rem;
    font-size: 0.94rem;
}
.accordion-flush > .accordion-item .accordion-button:focus {
    box-shadow: 0 0 0 3px var(--accent-tint);
    border-color: var(--accent);
    z-index: 1;
}
.accordion-flush > .accordion-item .accordion-body {
    background-color: transparent;
    padding: 0.3rem 0.4rem 1rem;
}
.accordion-button::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%234b5563'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
    transition: transform 0.2s ease;
}

.eval-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem; height: 1.55rem;
    border-radius: 50%;
    background-color: var(--accent-tint);
    color: var(--accent);
    font-size: 0.9rem;
    flex-shrink: 0;
}
.eval-label { flex: 1 1 auto; min-width: 0; }
.eval-summary {
    color: var(--text-muted);
    font-size: 0.78rem;
    padding-right: 0.45rem;
    font-weight: 400;
    text-align: right;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ───── Reference slider ───────────────────────────────────────────────── */
.ref-slider-group { display: flex; align-items: center; gap: 0.85rem; }
.ref-slider-group .form-range { flex: 1; }
.ref-slider-value {
    min-width: 2.6rem;
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.form-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    padding: 0;
    background: transparent;
}
.form-range:focus { outline: none; }
.form-range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background:
        linear-gradient(to right, var(--accent), var(--accent)) no-repeat,
        var(--border);
    background-size: var(--slider-fill, 25%) 100%;
}
.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -8px;
    width: 22px; height: 22px;
    background: var(--accent);
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(17, 20, 24, 0.18);
    cursor: pointer;
    transition: transform 0.1s ease;
}
.form-range::-webkit-slider-thumb:hover { transform: scale(1.1); }
.form-range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-tint); }
.form-range::-moz-range-track {
    height: 6px; border-radius: 3px; background: var(--border);
}
.form-range::-moz-range-progress {
    height: 6px; border-radius: 3px; background: var(--accent);
}
.form-range::-moz-range-thumb {
    width: 22px; height: 22px;
    background: var(--accent);
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(17, 20, 24, 0.18);
    cursor: pointer;
}

/* ───── Flavor wheel ───────────────────────────────────────────────────── */
.flavor-wheel {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.flavor-row { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.flavor-row.flavor-row-l2 {
    background-color: rgba(0, 0, 0, 0.035);
    border-radius: 0.55rem;
    padding: 0.55rem 0.7rem;
    margin: 0.1rem 0 0.1rem 1.5rem;
    animation: flavor-reveal 0.18s ease-out;
}
.flavor-row.flavor-row-l3 {
    background-color: rgba(0, 0, 0, 0.06);
    border-radius: 0.5rem;
    padding: 0.5rem 0.65rem;
    margin: 0.1rem 0 0.1rem 1.5rem;
    animation: flavor-reveal 0.18s ease-out;
}
@keyframes flavor-reveal {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.flavor-tag {
    --ft-color: var(--accent);
    display: inline-block;
    padding: 0.38em 0.9em;
    font-size: 0.82em;
    font-weight: 500;
    line-height: 1.1;
    border-radius: 999px;
    cursor: pointer;
    border: none;
    background-color: var(--bg-muted);
    color: var(--text-primary);
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
    user-select: none;
}
.flavor-tag:hover { background-color: var(--bg-muted-hover); transform: translateY(-1px); }
.flavor-tag.selected { background-color: var(--ft-color); color: #ffffff; }

/* ───── Tasting tag sections (氛圍/裝潢/服務 chips) ─────────────────────── */
.tag-section {
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
}
.tag-section:last-child { border-bottom: none; }
.tag-section-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.55rem;
    font-size: 0.92rem;
}
.tag-section-title .bi { color: var(--accent); }
.tag-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.tag-chip {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
}
.tag-chip:hover { color: var(--accent); border-color: var(--accent); }
.tag-chip.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ───── Bean type chips (單品 / 配方豆) ─────────────────────────────────── */
.bean-type-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.bean-type-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
}
.bean-type-chip:hover { color: var(--accent); border-color: var(--accent); }
.bean-type-chip.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.bean-type-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ───── Brewing method chips (耳掛包 / 手沖) ───────────────────────────── */
.brewing-method-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.brewing-method-chip {
    flex: 1 1 0;
    min-width: 110px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
}
.brewing-method-chip:hover { color: var(--accent); border-color: var(--accent); }
.brewing-method-chip.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.brewing-method-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ───── Sensory chip groups (感官 chip 快選) ───────────────────────────── */
.chip-group-label {
    display: block;
    margin: 0.75rem 0 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}
.chip {
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
    line-height: 1.3;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ───── Process chips (處理法選擇) ─────────────────────────────────────── */
.process-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.process-chip {
    flex: 0 1 auto;
    min-width: 80px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
}
.process-chip:hover { color: var(--accent); border-color: var(--accent); }
.process-chip.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.process-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ───── Item picker (品鑑點用品項：分類 → 品項，比照風味輪階層) ────────── */
.item-cat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
/* The item row reads as the active category's children: indented, shaded,
   revealed below the selected category — mirrors .flavor-row-l2. */
.item-chip-row:not(:empty) {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.035);
    border-radius: 0.55rem;
    padding: 0.55rem 0.7rem;
    margin: 0.3rem 0 0.1rem 1.5rem;
    animation: flavor-reveal 0.18s ease-out;
}
.item-cat-chip,
.item-chip {
    display: inline-block;
    padding: 0.38em 0.9em;
    font-size: 0.85em;
    font-weight: 500;
    line-height: 1.1;
    border-radius: 999px;
    cursor: pointer;
    border: none;
    background-color: var(--bg-muted);
    color: var(--text-primary);
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
    font-family: inherit;
}
.item-cat-chip { font-weight: 600; }
.item-cat-chip:hover,
.item-chip:hover { background-color: var(--bg-muted-hover); transform: translateY(-1px); }
.item-cat-chip.selected,
.item-chip.selected { background-color: var(--accent); color: #fff; }
.item-cat-chip:focus-visible,
.item-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ───── Estimated total (sensory eval) ─────────────────────────────────── */
.evaluation-estimated-total {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.6rem;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.evaluation-estimated-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}
.evaluation-estimated-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.evaluation-estimated-of { font-size: 0.78rem; color: var(--text-dim); }
.evaluation-estimated-tier {
    font-size: 0.92rem;
    font-weight: 700;
    padding-left: 0.4rem;
}
.evaluation-estimated-hint {
    flex-basis: 100%;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ───── Notes slot ─────────────────────────────────────────────────────── */
.notes-slot .notes-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    justify-content: center;
    padding: 0.4rem 0.7rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.notes-slot .notes-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background-color: var(--accent-tint);
}
.notes-slot.is-open .notes-toggle { display: none; }

/* ───── Page action bar (top-of-page CTA) ──────────────────────────────── */
.page-action-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.85rem;
}
.page-action-bar.shops-action-bar {
    justify-content: space-between;
    gap: 0.6rem;
    align-items: center;
}
.shops-search-input {
    flex: 1;
    min-width: 0;
    max-width: 360px;
}

/* ───── Action bar (form submit) ───────────────────────────────────────── */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

/* ───── Shops list ─────────────────────────────────────────────────────── */
.shops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.6rem;
}
.shop-card {
    display: block;
    padding: 0.85rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.shop-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}
.shop-card-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.3rem;
}
.shop-card-header .bi { color: var(--accent); }
.shop-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-card-loc {
    color: var(--text-muted);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.3rem;
}
.shop-card-intro {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ───── Shop detail ────────────────────────────────────────────────────── */
.shop-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.shop-detail-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.shop-detail-name .bi { color: var(--accent); }
.shop-detail-actions {
    display: flex;
    gap: 0.4rem;
}
.shop-detail-loc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}
.shop-detail-intro {
    color: var(--text-secondary);
    margin: 0;
    white-space: pre-wrap;
}

/* ───── Modal (shop create/edit) ───────────────────────────────────────── */
body.modal-open-custom { overflow: hidden; }
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(17, 20, 24, 0.45);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-shell {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
}
.modal-shell .modal-header {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 1;
}
.modal-shell .modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    flex: 1;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg-soft); color: var(--text-primary); }
.modal-shell .modal-body {
    padding: 1rem 1.1rem 1.1rem;
    flex: 1;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* ───── Google Places UI ──────────────────────────────────────────────── */
.sm-place-results { margin-top: 0.4rem; }
.sm-place-option {
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
}
.shop-place-badge {
    color: var(--accent);
    font-size: 0.85em;
    margin-left: 0.35rem;
    opacity: 0.85;
}
.bf-option {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.4rem;
    cursor: pointer;
    background: var(--bg-page);
}
.bf-option:hover {
    border-color: var(--accent);
}
.bf-option input[type="radio"] {
    margin-top: 0.25rem;
}
.bf-option-name {
    font-weight: 600;
    color: var(--text-primary);
}
.bf-option-addr {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ───── Misc ───────────────────────────────────────────────────────────── */
.small-hint { font-size: 0.8rem; color: var(--text-muted); }
hr { border-color: var(--border); opacity: 0.7; }
::selection { background-color: var(--accent-tint); color: var(--text-primary); }

.cloud-warning-msg {
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
    font-family: inherit;
}

.toast-msg {
    position: fixed;
    bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-page);
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1080;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.toast-msg.show { opacity: 1; }

/* ───── Read-only record detail view ──────────────────────────────────── */
.detail-back-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
}
.detail-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.92rem;
}
.detail-back-link:hover { color: var(--accent); }
.detail-header-card .detail-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.45rem;
    color: var(--text-primary);
}
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.85rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}
.detail-meta .bi { margin-right: 0.25rem; color: var(--text-dim); }
.detail-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 0.85rem;
    row-gap: 0.4rem;
    margin: 0;
}
.detail-list dt {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.88rem;
}
.detail-list dd {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.detail-eval-section {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}
.detail-eval-section:last-child { border-bottom: none; }
.detail-eval-section-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.45rem;
    font-size: 0.96rem;
    font-weight: 600;
    color: var(--text-primary);
}
.detail-eval-section-label { flex: 1; }
.detail-eval-score {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.detail-eval-row {
    display: flex;
    gap: 0.55rem;
    align-items: baseline;
    margin: 0.2rem 0;
}
.detail-eval-key {
    color: var(--text-muted);
    font-size: 0.85rem;
    min-width: 4.5rem;
}
.detail-eval-val {
    color: var(--text-primary);
    font-size: 0.92rem;
    flex: 1;
    overflow-wrap: anywhere;
}
.detail-eval-notes {
    margin: 0.45rem 0 0;
    padding: 0.5rem 0.7rem;
    background: var(--bg-soft);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.detail-flavor-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.45rem 0 0.2rem;
}
.detail-flavor-chip {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: var(--ft-color, var(--accent));
    color: #fff;
    font-size: 0.82rem;
    font-weight: 500;
}
.detail-tag-section { margin-bottom: 0.85rem; }
.detail-tag-section:last-child { margin-bottom: 0; }
.detail-tag-section-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.detail-tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.3rem;
}
.detail-tag-pill {
    padding: 0.18rem 0.65rem;
    background: var(--accent-tint);
    color: var(--accent);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
}
.detail-tag-notes {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin: 0;
    white-space: pre-wrap;
}

/* ───── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 576px) {
    .card-body { padding: 0.95rem; }
    .medal-row { gap: 0.45rem 0.55rem; margin-bottom: 1.25rem; }
    .medal-cell { min-width: 58px; }
    .tier-medal { width: 56px; height: 56px; }
    .tier-medal .medal-text { font-size: 1.5rem; }
    .medal-cell .medal-range-label { font-size: 0.68rem; }
    .coe-total-display { font-size: 1.85rem; }
    .accordion-flush > .accordion-item .accordion-button { padding: 0.6rem 0.3rem; font-size: 0.9rem; }
    .eval-icon { width: 1.4rem; height: 1.4rem; font-size: 0.82rem; }
    .flavor-row.flavor-row-l2,
    .flavor-row.flavor-row-l3 { margin-left: 1rem; }
    .filter-shop-wrap { margin-left: 0; width: 100%; }
    .filter-shop-wrap .form-select { width: 100%; min-width: 0; }
    .record-card-medal { width: 48px; height: 48px; }
    .record-card-medal-text { font-size: 0.95rem; }
    .shop-detail-name { font-size: 1.2rem; }
    .page-action-bar.shops-action-bar { flex-wrap: wrap; }
    .shops-search-input { max-width: none; flex-basis: 100%; }
    .new-mode-picker-btn { padding: 1.1rem 0.8rem; }
    .detail-header-card .detail-title { font-size: 1.15rem; }
}
