/* ===== FlipCard — Styles (site palette, aligned with personalos / timerecord) ===== */

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

:root {
    --primary-color:   #c1440e;
    --primary-dark:    #a3380c;
    --secondary-color: #8a5a2a;
    --success-color:   #3a9e5f;
    --danger-color:    #cc3333;
    --warning-color:   #c07a00;
    --bg-color:        #f5f0e8;
    --bg-secondary:    #ffffff;
    --bg-tertiary:     #faf6f0;
    --text-primary:    #1a1a1a;
    --text-secondary:  #7a5e4a;
    --border-color:    #e0d8cc;
    --shadow:          0 4px 6px rgba(0, 0, 0, 0.06);
    --shadow-md:       0 6px 14px rgba(0, 0, 0, 0.10);
    --shadow-lg:       0 14px 32px rgba(0, 0, 0, 0.16);
    --radius:          12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 20px 80px;
}

/* ---------- Header ---------- */
header { margin-bottom: 24px; }

.header-top {
    display: flex; justify-content: center; align-items: center;
    flex-wrap: wrap; gap: 15px; margin-bottom: 10px; position: relative;
}

.back-home {
    position: absolute; left: 0; width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); background: var(--bg-tertiary);
    border-radius: 8px; transition: all 0.3s ease;
    text-decoration: none; border: 1px solid var(--border-color);
}
.back-home:hover {
    color: var(--primary-color); background: var(--bg-secondary);
    transform: translateX(-2px); border-color: var(--primary-color);
}
.back-home svg { width: 20px; height: 20px; }

h1 { font-size: 2rem; font-weight: 700; color: var(--primary-color); margin: 0; }

.subtitle {
    color: var(--text-secondary); font-size: 0.95rem; text-align: center;
}

.header-actions {
    position: absolute; right: 0; display: flex; align-items: center; gap: 10px;
}

.language-select {
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 6px 12px; border-radius: 6px;
    cursor: pointer; font-size: 0.9rem; transition: border-color 0.3s ease;
}
.language-select:focus { outline: none; border-color: var(--primary-color); }

/* ---------- Auto-sync indicator ---------- */
/* Floats as a bottom-right toast so toggling between hidden/visible no longer
 * pushes the page content down (which caused the visible "downward jump" each
 * time a sync started or finished). Undo-toast lives at bottom-center, so the
 * two never overlap. */
.auto-sync-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem;
    padding: 6px 12px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}
.auto-sync-indicator.syncing { background: #f0f4ff; color: #5c6bc0; border: 1px solid #c5cae9; }
.auto-sync-indicator.success { background: #f0faf4; color: #2e7d52; border: 1px solid #a8d5b8; }
.auto-sync-indicator.error   { background: #fff3f0; color: var(--danger-color); border: 1px solid #fbd0c4; }
.auto-sync-indicator.fade-out { opacity: 0; transform: translateY(8px); }
@keyframes spin { to { transform: rotate(360deg); } }
.auto-sync-indicator.syncing svg { animation: spin 1s linear infinite; }

@media (max-width: 640px) {
    /* On phones, anchor a bit higher and use a less intrusive position so the
     * thumb-reach area at the bottom-right stays clear for native UI. */
    .auto-sync-indicator {
        bottom: 16px;
        right: 12px;
        font-size: 0.78rem;
        padding: 5px 10px;
    }
}

.hidden { display: none !important; }

/* ---------- Login hint ---------- */
.login-hint {
    background: #fff8ec; border: 1px solid #f1d9a8; color: #8a5a2a;
    padding: 8px 14px; border-radius: 8px; font-size: 0.88rem;
    margin-bottom: 14px; display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
}
.login-hint-btn {
    margin-left: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}
.login-hint-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

/* ---------- Site auth (mounted by ../js/site-auth.js into #siteAccountRoot) ---------- */
.site-account { display: inline-flex; align-items: center; }
.site-auth-header-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: inherit;
}
.site-auth-header-btn:hover { border-color: var(--primary-color); }

.site-account-logged { position: relative; }

.site-account-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 11rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    z-index: 10;
}
.site-account-dropdown-open { display: block; }

.site-account-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
}
.site-account-menu-item:hover { background: rgba(193, 68, 14, 0.08); }

.site-auth-dialog {
    position: fixed;
    inset: 0;
    width: 400px;
    max-width: calc(100vw - 32px);
    max-height: min(90vh, calc(100vh - 32px));
    height: fit-content;
    margin: auto;
    border: none;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-lg);
    overflow: auto;
}
.site-auth-dialog::backdrop { background: rgba(26, 26, 26, 0.45); }

.site-auth-dialog-inner { padding: 22px 22px 20px; }

.site-auth-dialog-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--text-primary);
}

.site-auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }

.site-auth-tab {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-family: inherit;
}
.site-auth-tab-active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-secondary);
    font-weight: 600;
}

.site-auth-field { margin-bottom: 12px; }

.site-auth-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.site-auth-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-sizing: border-box;
    font-family: inherit;
}
.site-auth-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(193, 68, 14, 0.1);
}

.site-auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.site-auth-btn-primary {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.site-auth-btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.site-auth-btn-primary:disabled { opacity: 0.65; cursor: not-allowed; }

.site-auth-btn-secondary {
    padding: 10px 18px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.site-auth-btn-secondary:hover { border-color: var(--primary-color); }

.site-auth-status { margin-top: 12px; font-size: 0.88rem; min-height: 1.25em; }
.site-auth-status-error   { color: #b42318; }
.site-auth-status-success { color: #027a48; }

/* ---------- List bar ---------- */
.list-bar {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.list-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.92rem;
    transition: all 0.2s ease;
    user-select: none;
}
.list-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #fff8f4;
}
.list-tab.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(193, 68, 14, 0.25);
}
.list-tab .list-tab-emoji { font-size: 1rem; }
.list-tab-add {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
}
.list-tab-add:hover {
    border-style: solid;
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: #fff8f4;
}

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 10px;
    align-items: center; justify-content: space-between;
    margin-bottom: 18px;
}
.toolbar-group {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.toolbar-group--right { margin-left: auto; }

.view-switch {
    display: inline-flex; border: 1px solid var(--border-color);
    border-radius: 8px; overflow: hidden; background: var(--bg-secondary);
}
.view-btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: none; cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease;
}
.view-btn svg { width: 16px; height: 16px; }
.view-btn:hover { color: var(--primary-color); }
.view-btn.active {
    background: var(--primary-color); color: #fff;
}

.sort-select {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 8px 10px; font-size: 0.9rem;
    color: var(--text-primary); cursor: pointer;
}
.sort-select:focus { outline: none; border-color: var(--primary-color); }

.btn-primary, .btn-secondary, .btn-danger, .btn-flip, .btn-link {
    border: none; cursor: pointer; font-size: 0.92rem; font-weight: 500;
    padding: 8px 16px; border-radius: 8px;
    transition: all 0.2s ease;
    display: inline-flex; align-items: center; gap: 6px;
    font-family: inherit;
}
.btn-primary {
    background: var(--primary-color); color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { background: #d8c2b6; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--bg-secondary); color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    border-color: var(--primary-color); color: var(--primary-color);
    background: #fff8f4;
}

.btn-danger {
    background: #fff; border: 1px solid #f1c0c0; color: var(--danger-color);
}
.btn-danger:hover { background: #ffeded; border-color: var(--danger-color); }

.btn-link {
    background: none; padding: 4px 0; color: var(--primary-color);
}
.btn-link:hover { text-decoration: underline; }

.btn-flip {
    background: linear-gradient(135deg, #c1440e 0%, #e07a3c 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(193, 68, 14, 0.30);
    padding: 9px 18px;
}
.btn-flip:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(193, 68, 14, 0.40);
}
.btn-flip:disabled {
    background: #d8c2b6; cursor: not-allowed;
    box-shadow: none; transform: none;
}
.btn-flip .flip-emoji { font-size: 1rem; }

.icon-btn {
    width: 36px; height: 36px;
    background: transparent; border: 1px solid var(--border-color);
    border-radius: 8px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: all 0.2s ease;
    font-family: inherit;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover {
    color: var(--primary-color); border-color: var(--primary-color);
    background: #fff8f4;
}
.icon-btn--danger:hover {
    color: var(--danger-color); border-color: var(--danger-color); background: #fff5f5;
}
.icon-btn.icon-btn--manual.is-active {
    color: var(--text-secondary);
    background: var(--bg-primary);
    border-color: #bbb;
}
.icon-btn.icon-btn--manual.is-active:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: #fff8f4;
}

/* ---------- Items area ---------- */
.items-area { min-height: 60px; }

.empty-state {
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* List view */
.items-area.view-list {
    display: flex; flex-direction: column; gap: 8px;
}
.items-area.view-list .item-card {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 14px; align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.items-area.view-list .item-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.items-area.view-list .item-body {
    min-width: 0;
}
.items-area.view-list .item-name {
    font-weight: 600; font-size: 1rem; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.items-area.view-list .item-summary {
    font-size: 0.85rem; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px;
}
.items-area.view-list .item-since {
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    text-align: right;
}
.items-area.view-list .item-since.never {
    color: var(--warning-color); font-weight: 500;
}
.items-area.view-list .item-rating { font-size: 0.85rem; color: var(--warning-color); white-space: nowrap; }
.items-area.view-list .item-name-row {
    display: flex; align-items: center; gap: 8px; min-width: 0;
}
.items-area.view-list .item-name-row .item-name { flex: 1; min-width: 0; }

/* Manual-only (greyed out) items — still openable for manual records */
.item-card.item-card--manual-only {
    opacity: 0.58;
    filter: grayscale(0.4);
}
.item-card.item-card--manual-only:hover {
    opacity: 0.78;
}
.item-manual-badge {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 1.4;
}
.items-area.view-grid .item-name {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}

/* Grid view */
.items-area.view-grid {
    display: grid;
    /* On desktop/tablet a 220px minimum keeps cards readable. The mobile
     * breakpoint below lowers this so phones get a 2-column grid instead of
     * one full-width column stretched to ~360px. */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.items-area.view-grid .item-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 130px;
    position: relative;
    overflow: hidden;
}
.items-area.view-grid .item-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--primary-color), #e07a3c);
    opacity: 0.7;
}
.items-area.view-grid .item-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.items-area.view-grid .item-name {
    font-weight: 600; font-size: 1.05rem; color: var(--text-primary);
    word-break: break-word;
}
.items-area.view-grid .item-summary {
    font-size: 0.85rem; color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
}
.items-area.view-grid .item-meta {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.82rem; color: var(--text-secondary);
    margin-top: auto;
}
.items-area.view-grid .item-since.never {
    color: var(--warning-color); font-weight: 500;
}
.items-area.view-grid .item-rating { color: var(--warning-color); }

/* Per-item avatar (auto-generated from name): keeps the row visually distinct
   instead of repeating the list-level emoji on every card. */
.item-avatar {
    width: 38px; height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    text-transform: uppercase;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.06);
    overflow: hidden;
    word-break: keep-all;
}
.item-avatar--lg {
    width: 52px; height: 52px;
    border-radius: 14px;
    font-size: 1.4rem;
    letter-spacing: 1px;
}

/* Highlight a card after a successful flip */
.item-card.flip-highlight {
    animation: flip-glow 2.4s ease;
}
@keyframes flip-glow {
    0%   { box-shadow: 0 0 0 4px rgba(193, 68, 14, 0); }
    25%  { box-shadow: 0 0 0 4px rgba(193, 68, 14, 0.45); transform: scale(1.02); }
    100% { box-shadow: 0 0 0 4px rgba(193, 68, 14, 0); }
}

/* ---------- Drawer ---------- */
.drawer-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
    z-index: 50; backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(480px, 100vw);
    background: var(--bg-secondary);
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.18);
    z-index: 51;
    display: flex; flex-direction: column;
    animation: slideInRight 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.drawer-title {
    font-size: 1.2rem; font-weight: 600; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0; padding-right: 12px;
}
.drawer-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.drawer-content {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}
.drawer-section {
    margin-bottom: 28px;
}
.drawer-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Record form */
.record-form {
    display: flex; flex-direction: column; gap: 12px;
}
.record-form .field-row {
    display: flex; flex-direction: column; gap: 4px;
}
.record-form label {
    font-size: 0.85rem; color: var(--text-secondary);
    display: flex; gap: 4px; align-items: center;
}
.record-form label .required { color: var(--danger-color); }
.record-form .input,
.record-form textarea,
.record-form select {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.record-form .input:focus,
.record-form textarea:focus,
.record-form select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}
.record-form textarea { min-height: 70px; resize: vertical; line-height: 1.55; }
.record-form .form-actions {
    display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px;
}

/* Rating widget */
.rating-input {
    display: inline-flex; gap: 4px;
}
.rating-input button {
    background: none; border: none; cursor: pointer;
    font-size: 1.4rem; line-height: 1;
    color: #d6c8b8;
    padding: 0 2px;
    transition: color 0.15s ease, transform 0.15s ease;
    font-family: inherit;
}
.rating-input button:hover { transform: scale(1.15); }
.rating-input button.filled { color: #f0a04b; }
.rating-input button.zero { font-size: 0.8rem; color: var(--text-secondary); padding: 0 6px; }

/* Record history list */
.record-history { display: flex; flex-direction: column; gap: 10px; }
.record-history-empty {
    padding: 20px; text-align: center; font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary); border-radius: 8px;
}
.record-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    position: relative;
}
.record-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px; gap: 8px;
}
.record-card-time {
    font-size: 0.82rem; color: var(--text-secondary);
}
.record-card-actions {
    display: flex; gap: 4px;
}
.record-card-actions button {
    width: 26px; height: 26px;
    border: none; background: transparent; cursor: pointer;
    color: var(--text-secondary); border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: inherit;
}
.record-card-actions button:hover { background: var(--bg-secondary); color: var(--primary-color); }
.record-card-actions button.danger:hover { color: var(--danger-color); }
.record-card-actions svg { width: 14px; height: 14px; }
.record-card-fields {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 0.92rem;
}
.record-card-field {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.record-card-field-label {
    color: var(--text-secondary); flex-shrink: 0; min-width: 70px;
}
.record-card-field-value {
    color: var(--text-primary); white-space: pre-wrap; word-break: break-word; flex: 1;
}
.record-card-rating { color: var(--warning-color); }

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
    z-index: 60; backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
}
.modal {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 61;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    display: flex; flex-direction: column;
    animation: modalIn 0.2s ease;
}
.modal--small { width: min(420px, calc(100vw - 32px)); }
@keyframes modalIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.modal-header h2 { font-size: 1.15rem; color: var(--text-primary); margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex; gap: 10px; align-items: center;
}
.modal-footer-spacer { flex: 1; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 0.88rem; color: var(--text-secondary); font-weight: 500; }
.form-group--grow { flex: 1; }
.form-group--emoji { width: 100px; flex-shrink: 0; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }

.input {
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 9px 12px; font-size: 0.95rem;
    color: var(--text-primary); font-family: inherit;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.input:focus { outline: none; border-color: var(--primary-color); background: var(--bg-secondary); }
.input--emoji { text-align: center; font-size: 1.4rem; }

.form-error {
    background: #fff3f0; color: var(--danger-color);
    border: 1px solid #fbd0c4; padding: 8px 12px;
    border-radius: 8px; font-size: 0.88rem;
}

/* Template picker */
.template-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}
.template-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-primary);
    font-family: inherit;
}
.template-card:hover { border-color: var(--primary-color); background: #fff8f4; }
.template-card.active {
    border-color: var(--primary-color); background: #fff8f4;
    box-shadow: 0 0 0 1px var(--primary-color) inset;
}
.template-card-emoji { font-size: 1.6rem; }

/* Field editor */
.field-editor { display: flex; flex-direction: column; gap: 8px; }
.field-row-edit {
    display: grid;
    grid-template-columns: 1fr 130px auto auto;
    gap: 8px;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
}
.field-row-edit input,
.field-row-edit select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    min-width: 0;
}
.field-row-edit .field-required-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.82rem; color: var(--text-secondary);
    cursor: pointer; user-select: none;
}
.field-row-edit .field-remove-btn {
    width: 28px; height: 28px;
    background: transparent; border: 1px solid transparent;
    border-radius: 6px; cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: inherit;
}
.field-row-edit .field-remove-btn:hover {
    color: var(--danger-color); background: #fff5f5;
}
.field-row-edit .field-remove-btn svg { width: 14px; height: 14px; }

/* ---------- Flip overlay (modal) ---------- */
.flip-overlay {
    position: fixed; inset: 0; background: rgba(20, 12, 6, 0.78);
    z-index: 70;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.25s ease;
    padding: 20px;
}
.flip-modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: min(720px, 100%);
    max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    animation: modalIn 0.25s ease;
}
.flip-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.flip-modal-header h2 { font-size: 1.2rem; color: var(--primary-color); }

.flip-modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1;
}

.flip-options {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.flip-option {
    display: inline-flex; align-items: center; gap: 8px;
    cursor: pointer; user-select: none;
}
.flip-option input { cursor: pointer; }

.flip-stage {
    perspective: 1000px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    /* Gap accommodates the scale(1.12) growth on chosen cards (~6% per side)
     * plus a few pixels of breathing room so adjacent winners don't collide. */
    gap: 16px;
    min-height: 240px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.flip-card-wrap {
    aspect-ratio: 2 / 3;
    perspective: 800px;
}
.flip-card-inner {
    position: relative;
    width: 100%; height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.5, 0, 0.5, 1);
}
.flip-card-wrap.is-flipped .flip-card-inner {
    transform: rotateY(180deg);
}
/* The is-shaking class is toggled on a different card every flip cycle.
 * The JS interval is dynamic (~70-260ms), so the shake animation duration
 * is intentionally a bit shorter than the slowest cycle to feel snappy at
 * the slow ends without getting cut off mid-frame in the fast middle.
 */
.flip-card-wrap.is-shaking {
    animation: card-pulse 0.22s ease-out;
    z-index: 2;
}
.flip-card-wrap.is-shaking .flip-card-inner {
    animation: card-shake 0.22s ease-out;
}
/* IMPORTANT: every frame must include rotateY(180deg) so the front face stays
 * visible during the shake. Otherwise the keyframe's transform overrides the
 * rotateY(180deg) that .is-flipped sets, and the card briefly flips back to
 * its default (back-face) state — the "weird middle frame" symptom. */
@keyframes card-shake {
    0%   { transform: rotateY(180deg) rotateZ(0deg) translateY(0) scale(1); }
    30%  { transform: rotateY(180deg) rotateZ(-4deg) translateY(-5px) scale(1.06); }
    60%  { transform: rotateY(180deg) rotateZ(4deg) translateY(-3px) scale(1.04); }
    100% { transform: rotateY(180deg) rotateZ(0deg) translateY(0) scale(1); }
}
@keyframes card-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(193, 68, 14, 0); }
    50%  { box-shadow: 0 0 0 6px rgba(193, 68, 14, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(193, 68, 14, 0); }
}

.flip-face {
    position: absolute; inset: 0;
    border-radius: 8px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    padding: 8px;
    user-select: none;
}
.flip-face-back {
    background: linear-gradient(135deg, #c1440e 0%, #8a3007 100%);
    color: #f5e6d6;
    border: 2px solid #fff8ec;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.25);
    font-size: 1.6rem;
}
.flip-face-back::before {
    content: '🎴'; font-size: 2rem; opacity: 0.92;
}
.flip-face-front {
    background: var(--bg-secondary);
    border: 2px solid var(--primary-color);
    color: var(--text-primary);
    transform: rotateY(180deg);
    box-shadow: 0 0 12px rgba(193, 68, 14, 0.45);
    gap: 8px;
}
.flip-face-front .item-avatar--lg {
    width: 44px; height: 44px;
    border-radius: 12px;
    font-size: 1.2rem;
}
.flip-face-front .flip-face-name {
    font-weight: 600; font-size: 0.9rem;
    line-height: 1.3;
    word-break: break-word;
    overflow: hidden; display: -webkit-box;
    -webkit-line-clamp: 3; -webkit-box-orient: vertical; line-clamp: 3;
}

.flip-card-wrap.is-chosen .flip-card-inner {
    /* Same rotation as .is-flipped (front face visible) — keeping the angle
     * identical means the class swap animates only the scale, no rotation. */
    transform: rotateY(180deg) scale(1.12);
    z-index: 2;
}
.flip-card-wrap.is-chosen .flip-face-front {
    border-color: #f0a04b;
    box-shadow: 0 0 24px 6px rgba(240, 160, 75, 0.65);
}
/* When at least one winner exists, dim the rest so the reveal pops. The JS
 * adds .has-winners to .flip-stage once the reveal lands. */
.flip-stage.has-winners .flip-card-wrap:not(.is-chosen) {
    opacity: 0.45;
    filter: saturate(0.7);
    transition: opacity 0.35s ease, filter 0.35s ease;
}

.flip-result {
    margin-top: 14px;
    text-align: center;
    padding: 14px;
    background: linear-gradient(135deg, #fff8ec 0%, #fff3e1 100%);
    border: 1px solid #f1d9a8;
    border-radius: 10px;
    animation: fadeInUp 0.35s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.flip-result-label {
    font-size: 0.9rem; color: var(--text-secondary);
}
.flip-result-name {
    margin-top: 6px;
    font-size: 1.4rem; font-weight: 700;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}
.flip-result-name .item-avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 0.95rem; }

.flip-modal-footer {
    padding: 14px 20px; border-top: 1px solid var(--border-color);
    display: flex; gap: 10px; align-items: center;
}

.flip-empty {
    padding: 30px; text-align: center;
    color: var(--text-secondary); font-size: 0.95rem;
    grid-column: 1 / -1;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 26, 26, 0.92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.92rem;
    z-index: 100;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.25s ease;
    pointer-events: none;
}
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
.toast.fade-out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, 8px); }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .container { padding: 16px 14px 60px; }
    h1 { font-size: 1.6rem; }
    .header-actions { position: static; }
    /* Stack the two toolbar groups vertically and let each one fill its row.
     * The previous rule kept the right group right-aligned on its own line,
     * which left a big awkward void on the left of the row. space-between
     * spreads the buttons evenly across the row instead. */
    .toolbar {
        gap: 10px;
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar-group {
        width: 100%;
        justify-content: space-between;
    }
    .toolbar-group--right {
        margin-left: 0;
        justify-content: space-between;
    }
    /* Sort dropdown takes the remaining row width so the left group spans
     * the full line, balancing the right row visually. */
    .sort-select { flex: 1 1 auto; min-width: 0; }
    /* Tighten button padding so all four right-group buttons fit on one row
     * even with the narrowest mainstream phone widths (320–360px). */
    .toolbar-group--right .btn-secondary,
    .toolbar-group--right .btn-flip {
        padding-left: 12px;
        padding-right: 12px;
        font-size: 0.9rem;
    }
    .drawer { width: 100vw; }
    .field-row-edit {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        row-gap: 8px;
    }
    .field-row-edit .field-required-toggle,
    .field-row-edit .field-remove-btn {
        grid-column: span 1;
    }
    .flip-stage {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    /* Phones: force a 2-column card grid. With auto-fill at the 220px desktop
     * minimum, iPhone-class widths (≤390 content) only fit one column and the
     * cards stretched edge-to-edge (the "weird stretched card" symptom). */
    .items-area.view-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .items-area.view-grid .item-card {
        padding: 12px;
        min-height: 110px;
        gap: 8px;
    }
    .items-area.view-grid .item-name { font-size: 0.98rem; }
    .items-area.view-grid .item-avatar { width: 34px; height: 34px; font-size: 1rem; }
}

/* ===== v2 additions ===== */

/* --- Filter row: search + tag chips --- */
.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.search-box {
    position: relative;
    flex: 1 1 220px;
    max-width: 360px;
}
.search-box svg {
    position: absolute;
    left: 10px; top: 50%;
    width: 16px; height: 16px;
    transform: translateY(-50%);
    color: var(--text-secondary);
    opacity: 0.6;
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.92rem;
    transition: border-color 0.2s ease;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tag-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1 1 200px;
}
.tag-filter-bar.hidden { display: none; }
.tag-chip {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.tag-chip:hover { background: var(--bg-tertiary); }
.tag-chip.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* --- More menu (dropdown) --- */
.more-menu-wrap {
    position: relative;
    display: inline-block;
}
.more-menu-btn {
    padding: 8px;
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
}
.more-menu-btn svg { width: 18px; height: 18px; }
.more-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    z-index: 80;
    padding: 6px;
    display: flex; flex-direction: column;
}
.more-menu.hidden { display: none; }
.more-menu-item {
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.92rem;
    cursor: pointer;
}
.more-menu-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

/* --- Item tag badges on cards --- */
.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.item-tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    line-height: 1.2;
}
.items-area.view-grid .item-tags { justify-content: center; }

.filter-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 0.95rem;
}

/* --- Modal extras --- */
.modal-hint {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 8px;
}
.modal-code-example {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    margin-bottom: 12px;
}
.modal--small { max-width: 420px; }
.form-info {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--primary-color);
    padding: 8px 12px;
    margin-top: 8px;
    border-radius: 4px;
    font-size: 0.88rem;
    color: var(--text-primary);
}
.import-textarea {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 180px;
}
.radio-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 0.92rem;
}

/* --- Export format buttons --- */
.export-format-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.export-fmt-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.15s ease;
}
.export-fmt-btn:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.export-fmt-emoji { font-size: 1.4rem; }

/* --- Stats modal --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 12px;
    text-align: center;
}
.stat-card-num {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}
.stat-card-lbl {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 4px;
}
.stats-section-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 18px 0 8px;
    font-weight: 600;
}
.stat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.stat-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.92rem;
}
.stat-list li:last-child { border-bottom: none; }
.stat-list b {
    color: var(--primary-color);
    font-weight: 600;
}
.stat-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.stat-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.stat-empty {
    color: var(--text-secondary);
    font-size: 0.88rem;
    padding: 4px 0;
}

/* Heatmap */
.heatmap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 4px;
}
.heat-row {
    display: flex;
    gap: 3px;
}
.heat-cell {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}
.heat-1 { background: #f4d0c0; }
.heat-2 { background: #e89e7a; }
.heat-3 { background: #d27044; }
.heat-4 { background: var(--primary-color); border-color: var(--primary-dark); }

/* --- Undo toast --- */
.undo-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #2a2a2a;
    color: #f5f0e8;
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 200;
    font-size: 0.92rem;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.undo-toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }
.undo-toast.visible { opacity: 1; }
.undo-toast-btn {
    background: transparent;
    border: 1px solid rgba(245, 240, 232, 0.4);
    color: #f5f0e8;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
}
.undo-toast-btn:hover {
    background: rgba(245, 240, 232, 0.1);
    border-color: #f5f0e8;
}

/* --- Flip settings collapsible --- */
/* The flip modal panel itself is white (--bg-secondary), so all settings UI
 * uses the site's regular text/background tokens for legibility. The earlier
 * version inherited a dark-mode skin which rendered as faint white-on-white.
 */
.flip-settings {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}
.flip-settings summary {
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
    list-style: none;
}
.flip-settings summary:hover { background: rgba(193, 68, 14, 0.05); }
.flip-settings summary::-webkit-details-marker { display: none; }
.flip-settings summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    color: var(--primary-color);
    transition: transform 0.2s ease;
}
.flip-settings[open] summary::before { transform: rotate(90deg); }
.flip-settings[open] summary {
    border-bottom: 1px solid var(--border-color);
    background: rgba(193, 68, 14, 0.04);
}
.flip-settings-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-secondary);
}
.flip-settings-body .flip-option {
    color: var(--text-primary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.flip-option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.flip-option-row label {
    color: var(--text-primary);
    font-weight: 500;
}
.flip-option-row .input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
}
.flip-option-row .input:focus {
    outline: none;
    border-color: var(--primary-color);
}
.flip-tag-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}
.flip-tag-chip {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.flip-tag-chip:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.flip-tag-chip.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.flip-empty {
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 24px 16px;
    border-radius: 10px;
    margin: 20px 0;
    font-size: 0.95rem;
}
.flip-result-sep {
    color: var(--text-secondary);
    margin: 0 6px;
}

/* --- AI parse section in drawer --- */
.ai-parse-section {
    background: linear-gradient(135deg, #fef4e8, #faecde);
    border: 1px solid #f0d8b8;
    border-radius: 10px;
    margin-bottom: 16px;
}
.ai-parse-section summary {
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    color: var(--primary-dark);
    font-size: 0.92rem;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-parse-section summary::-webkit-details-marker { display: none; }
.ai-parse-section summary::after {
    content: '▾';
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.6;
}
.ai-parse-section[open] summary::after { transform: rotate(180deg); }
.ai-parse-icon { font-size: 1.05rem; }
.ai-parse-body {
    padding: 4px 14px 14px;
}
.ai-parse-input {
    width: 100%;
    resize: vertical;
    min-height: 64px;
    margin-top: 6px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.7);
}
.ai-parse-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ai-parse-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex: 1;
}
.ai-parse-status.ok { color: var(--success-color); }
.ai-parse-status.error { color: var(--danger-color); }

@media (max-width: 640px) {
    .filter-row { flex-direction: column; align-items: stretch; }
    /* When .filter-row switches to column, the original `flex: 1 1 220px`
     * on .search-box is interpreted as a 220px main-axis (height) basis,
     * leaving a huge blank below the input. Reset flex so the box hugs
     * the input's natural height. */
    .search-box { max-width: none; flex: 0 0 auto; }
    .more-menu { right: auto; left: 0; }
}

/* ---------- Share modal ---------- */
.share-body { display: block; }
.share-link-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.share-link-input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.86rem;
    background: var(--bg-tertiary);
}
.share-link-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.share-status-hint {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-height: 1em;
}
.share-status-hint--disabled {
    color: var(--warning-color);
    font-weight: 500;
}
.share-privacy-hint {
    margin-top: 14px;
    margin-bottom: 0;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.82rem;
}
@media (max-width: 640px) {
    .share-link-row { flex-direction: column; }
    .share-link-row .btn-primary { width: 100%; justify-content: center; }
}
