body { font-family: 'Noto Sans TC', sans-serif; background-color: #f7f5f2; color: #333; }
.brand-banner {
    height: 40px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}
@media (min-width: 768px) {
    .brand-banner { height: 48px; }
}
#authSection .brand-banner {
    height: 120px;
    margin-left: auto;
    margin-right: auto;
}
@media (min-width: 768px) {
    #authSection .brand-banner { height: 140px; }
}
.font-serif { font-family: 'Cormorant Garamond', serif; }
.brand-blue { background-color: #c8785a; }
.brand-blue-hover { background-color: #b5664a; }
.brand-text-blue { color: #c8785a; }
.bg-brand-light { background-color: #eeebe6; }
.border-brand-light { border-color: #e5e7eb; }
.input-underline { border-bottom: 1px solid #e5e7eb; background: transparent; padding: 0.5rem 0; }
.input-underline:focus { outline: none; border-color: #c8785a; }
.input-placeholder-center::placeholder { text-align: center; color: #b1b1b1; font-size: 0.875rem; }
.step-header { display: flex; align-items: center; margin-bottom: 1rem; }
.step-number { background-color: #c8785a; color: white; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; margin-right: 0.75rem; flex-shrink: 0;}
.step-title { font-size: 0.95rem; letter-spacing: 0.05em; color: #4a4a4a; font-weight: 500; }
.input-line {
    border: none;
    border-bottom: 1px solid #e5e7eb;
    background: transparent;
    padding: 0.4rem 0;
    width: 100%;
    font-size: 0.875rem;
}
.input-line:focus { outline: none; border-color: #c8785a; }
select.input-line {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 1.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.25rem center;
    background-size: 10px;
    border-radius: 0;
}
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.tab-bar { position: fixed; bottom: 0; left: 0; right: 0; background: white; border-top: 1px solid #e5e7eb; display: flex; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom); z-index: 50; }
.tab-item { flex: 1; text-align: center; padding: 0.5rem; cursor: pointer; font-size: 0.75rem; color: #9ca3af; transition: color 0.2s; }
.tab-item.active { color: #c8785a; }
.tab-item.active .tab-icon { color: #c8785a; }
.tab-icon { font-size: 1.5rem; display: block; margin-bottom: 0.25rem; }
@media (min-width: 768px) {
    .tab-bar { position: static; display: none; }
    .desktop-tabs { display: flex; border-bottom: 1px solid #e5e7eb; margin-bottom: 2rem; }
    .desktop-tab { padding: 1rem 2rem; cursor: pointer; border-bottom: 2px solid transparent; color: #9ca3af; font-weight: 500; transition: color 0.2s; }
    .desktop-tab.active { color: #c8785a; border-bottom-color: #c8785a; }
}
@media (max-width: 767px) {
    body { padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }
    .tab-content { padding-bottom: 2rem; }
}
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 60; }
.yarn-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #e5e7eb; border-top: none; max-height: 200px; overflow-y: auto; z-index: 10; }
.yarn-dropdown-item { padding: 0.5rem; cursor: pointer; font-size: 0.875rem; color: #4a4a4a; }
.yarn-dropdown-item:hover { background-color: #eeebe6; }
.search-status { font-size: 0.75rem; color: #9ca3af; margin-top: 0.25rem; }
.modal-content { background: white; border-radius: 8px; padding: 2rem; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; }
/* Mobile: full-width modal that survives the on-screen keyboard.
   dvh = dynamic viewport height (shrinks when keyboard appears),
   keeping the textarea reachable above the keyboard. */
@media (max-width: 768px) {
    .modal-overlay { align-items: flex-start; padding: 16px 12px; }
    .modal-content {
        width: 100%;
        max-width: 100%;
        padding: 1.25rem;
        max-height: calc(100vh - 32px); /* fallback for browsers without dvh */
        max-height: calc(100dvh - 32px);
    }
    /* Bigger edit-log textarea on mobile so long Chinese bodies are readable */
    .log-edit-body { min-height: 220px; font-size: 16px; }
}
.border-brand { border-color: #c8785a !important; }
.text-brand { color: #c8785a !important; }
.onboarding-modal { position: fixed; inset: 0; background: white; display: flex; align-items: center; justify-content: center; z-index: 50; }
.onboarding-content { text-align: center; max-width: 500px; width: 90%; }

.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── My Swatches: fixed-height card grid ── */
.swatch-card {
    display: flex;
    flex-direction: column;
    height: 384px;
    overflow: hidden;
}
.swatch-card-media {
    height: 176px;
    flex-shrink: 0;
    overflow: hidden;
}
.swatch-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.swatch-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eeebe6;
    color: #b3aaa0;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
}
.swatch-card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
}
.swatch-card-head {
    height: 58px;
    flex-shrink: 0;
    overflow: hidden;
}
.swatch-card-foot {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Tool sub-tab pills */
.tool-pill {
    padding: 6px 16px; border-radius: 20px; font-size: 0.75rem;
    border: 1.5px solid rgba(44,31,20,0.12); background: #f7f5f2;
    color: #6b4c35; cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.tool-pill.active { background: #2c2826; color: white; border-color: #2c2826; }
.tool-pill:hover:not(.active) { border-color: #c8785a; color: #c8785a; }

/* Gallery tile */
.gallery-tile { position: relative; aspect-ratio: 1; overflow: hidden; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: rgba(200,120,90,0.15); }
.gallery-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; pointer-events: none; }
.gallery-tile:hover img { transform: scale(1.05); }
.gallery-tile .gallery-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.55);
    opacity: 0; transition: opacity 0.2s; display: flex; align-items: end; padding: 10px;
    pointer-events: none; /* taps always reach .gallery-tile, never get swallowed by the overlay */
}
.gallery-tile:hover .gallery-overlay { opacity: 1; }
/* 手機：改成底部半透明文字條，常駐顯示 */
@media (hover: none) {
    .gallery-tile .gallery-overlay {
        opacity: 1; inset: auto 0 0 0; background: linear-gradient(transparent, rgba(0,0,0,0.6));
        padding: 16px 8px 6px;
    }
}
.gallery-tile .gallery-overlay p { color: white; font-size: 0.75rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.gallery-tile .gallery-tag { position: absolute; top: 6px; left: 6px; font-size: 0.65rem; background: rgba(255,255,255,0.85); padding: 1px 6px; border-radius: 999px; z-index: 2; }

/* Timeline (desktop horizontal) */
.h-timeline-wrap { position: relative; margin-top: 4px; }
.h-timeline {
    display: flex;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px 0 200px;
    margin: 0 30px;
    position: relative;
}
.h-timeline::before {
    content: '';
    position: absolute;
    top: 35px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e5e7eb;
    z-index: 0;
}
.tl-dot-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    flex-shrink: 0;
    cursor: pointer;
    z-index: 1;
    padding: 8px 0;
}
.tl-tag-label {
    display: block;
    height: 14px;
    line-height: 14px;
    font-size: 0.6rem;
    color: #777;
    margin-bottom: 4px;
    max-width: 70px;
    padding: 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.tl-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 2px #e5e7eb;
    transition: transform 0.2s, box-shadow 0.2s;
}
.tl-dot-wrap:hover .tl-dot { transform: scale(1.5); }
.tl-date {
    font-size: 0.6rem;
    color: #9ca3af;
    margin-top: 6px;
    white-space: nowrap;
}
/* Popup positioned by JS via position:fixed so it escapes the
   timeline's horizontal-scroll overflow clip (otherwise the left
   edge of the popup gets cut off near the strip's left boundary). */
.tl-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    border-radius: 8px;
    width: 340px;
    max-width: calc(100vw - 24px);
    overflow: hidden;
    z-index: 100;
}
.tl-dot-wrap.tl-hover .tl-popup { display: block; }
.tl-popup img { width: 100%; height: 140px; object-fit: cover; display: block; }
.tl-popup-text {
    padding: 12px 16px;
    font-size: 0.8rem;
    color: #555;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* Mobile (≤ 768px): vertical timeline with inline content (no hover/tap reveal) */
@media (max-width: 768px) {
    .h-timeline-wrap { margin-top: 8px; }
    .h-timeline {
        flex-direction: column;
        align-items: stretch;
        overflow-x: visible;
        overflow-y: visible;
        padding: 0 0 0 24px;
        margin: 0;
        gap: 0;
    }
    .h-timeline::before {
        top: 14px;
        bottom: 14px;
        left: 7px;
        right: auto;
        width: 2px;
        height: auto;
    }
    .tl-dot-wrap {
        flex-direction: row;
        align-items: flex-start;
        width: 100%;
        min-width: 0;
        padding: 14px 4px 14px 16px;
        gap: 0;
        border-bottom: 1px solid #f3f4f6;
    }
    .tl-dot-wrap:last-child { border-bottom: none; }
    .tl-dot-wrap:hover .tl-dot { transform: none; }
    .tl-dot {
        position: absolute;
        left: -22px;
        top: 18px;
        width: 14px;
        height: 14px;
        margin: 0 !important;
        flex-shrink: 0;
    }
    /* Hide compact tag label — full tag shows inline inside popup-text */
    .tl-tag-label { display: none !important; }
    /* Date floats top-right of the row */
    .tl-date {
        position: absolute;
        top: 16px;
        right: 4px;
        font-size: 0.7rem;
        color: #9ca3af;
        margin: 0;
        flex-shrink: 0;
    }
    /* Popup becomes always-visible inline content */
    .tl-popup {
        display: flex !important;
        position: static !important;
        transform: none !important;
        left: auto;
        top: auto;
        width: 100%;
        flex-direction: row;
        align-items: stretch;
        gap: 12px;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
        z-index: auto;
    }
    .tl-popup img {
        width: 64px;
        height: 64px;
        flex-shrink: 0;
        border-radius: 6px;
        object-fit: cover;
    }
    .tl-popup-text {
        padding: 0;
        padding-right: 56px;
        font-size: 0.85rem;
        color: #4a4a4a;
        line-height: 1.5;
        flex: 1;
        min-width: 0;
        -webkit-line-clamp: 4;
        max-width: 100%;
    }
}

/* Mobile timeline (rendered by renderTimelineMobile in journal.js).
   Vertical list: dot on the left rail, thumbnail + meta + body inline.
   No hover/tap reveal — everything is visible. */
.m-timeline {
    position: relative;
    padding-left: 24px;
    margin-top: 8px;
}
.m-timeline::before {
    content: '';
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: 7px;
    width: 2px;
    background: #e5e7eb;
}
.m-tl-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 4px 14px 0;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(200,120,90,0.10);
}
.m-tl-row:last-child { border-bottom: none; }
.m-tl-dot {
    position: absolute;
    left: -21px;
    top: 18px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 2px #e5e7eb;
    z-index: 1;
}
.m-tl-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #eeebe6;
}
.m-tl-thumb-empty { background: #f1efeb; }
.m-tl-content { flex: 1; min-width: 0; }
.m-tl-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.m-tl-tag {
    font-size: 0.65rem;
    padding: 1px 8px;
    border-radius: 999px;
    background: #eeebe6;
    color: #6b4c35;
    white-space: nowrap;
}
.m-tl-date {
    font-size: 0.7rem;
    color: #9ca3af;
}
.m-tl-body {
    font-size: 0.85rem;
    color: #4a4a4a;
    line-height: 1.5;
    margin: 0;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Improve tap responsiveness on mobile for journal cards/dots */
.tl-dot-wrap,
.log-grid-card { touch-action: manipulation; -webkit-tap-highlight-color: rgba(200,120,90,0.10); }
