:root {
    --bg: #f6f2ed;
    --card: #ffffff;
    --soft-shadow: 0 6px 24px rgba(0,0,0,0.04);
    --text: #2c2520;
    --muted: #8a7a6e;
    --warm: #c97b63;
    --rose: #d4a09b;
    --sage: #84a98c;
    --border: #ece3db;
    --radius: 20px;
    --slider-bg: linear-gradient(to right, #84a98c, #ece3db 40%, #d4a09b 70%, #c97b63 100%);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1816;
        --card: #28221e;
        --text: #f0ebe5;
        --muted: #a09082;
        --border: #3d3430;
        --soft-shadow: 0 6px 24px rgba(0,0,0,0.5);
        /* 深色模式高對比度滑塊軌道 */
        --slider-bg: linear-gradient(to right, #52796f, #3d3430 40%, #b5838d 70%, #e07a5f 100%);
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
    line-height: 1.7;
    padding: 20px 16px 40px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    transition: background 0.3s;
}

/* ♿ Skip Link */
.skip-link {
    position: absolute;
    top: -50px;
    left: 16px;
    background: var(--warm);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 8px;
    z-index: 9999;
    text-decoration: none;
    font-weight: 500;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 16px;
}

/* 輔助技術專用隱藏 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.container { max-width: 640px; width: 100%; }

.top-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}

.lang-btn, .sos-mini-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 14px;
    min-height: 36px;
    border-radius: 30px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.lang-btn.active { background: var(--warm); color: #fff; border-color: var(--warm); }
.sos-mini-btn { border-color: var(--rose); color: var(--rose); font-weight: 500; }

.hero { text-align: center; padding: 10px 0 16px; }
.hero h1 { font-size: 1.8rem; font-weight: 500; letter-spacing: 1px; color: var(--text); }
.hero p { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px 20px;
    margin-bottom: 18px;
    box-shadow: var(--soft-shadow);
    border: 1px solid var(--border);
    transition: background 0.3s, border 0.3s;
}

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

.breath-area { text-align: center; padding: 6px 0; }
.breath-circle {
    width: 80px; height: 80px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(132,169,140,0.15) 0%, transparent 70%);
    border: 2px solid var(--sage);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--sage);
    transition: transform 3.8s ease-in-out, border-color 0.3s;
    cursor: default;
}
.breath-inhale { transform: scale(1.35); border-color: var(--sage); }
.breath-hold { transform: scale(1.35); border-color: var(--warm); color: var(--warm); }
.breath-exhale { transform: scale(1.0); border-color: var(--rose); color: var(--rose); }
.breath-hint { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.tag-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.tag {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 8px 16px;
    min-height: 40px;
    border-radius: 30px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.15s;
    display: inline-flex;
    align-items: center;
}
.tag.active { background: var(--warm); color: #fff; border-color: var(--warm); }

.slider-wrap { margin: 16px 0 8px; }
.slider-header { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); }
#sudsValue { color: var(--warm); }
.slider-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

#sudsSlider {
    width: 100%; height: 6px;
    -webkit-appearance: none; appearance: none;
    background: var(--slider-bg);
    border-radius: 4px; outline: none; margin: 12px 0;
}
#sudsSlider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--warm); cursor: pointer; border: 2px solid var(--card);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tabs {
    display: flex; gap: 4px; background: var(--bg);
    border-radius: 40px; padding: 4px; margin: 14px 0 12px;
}
.tab {
    flex: 1; background: transparent; border: none;
    color: var(--muted); padding: 10px 6px; border-radius: 30px;
    font-size: 0.85rem; cursor: pointer; transition: 0.2s; min-height: 44px;
}
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.04); font-weight: 500; }

textarea, input[type="text"], input[type="password"] {
    width: 100%; padding: 14px 16px; border-radius: 14px;
    border: 1px solid var(--border); background: var(--bg);
    color: var(--text); font-size: 0.95rem; line-height: 1.6; font-family: inherit;
}
textarea { min-height: 140px; resize: vertical; }
input[type="text"], input[type="password"] { margin: 6px 0; min-height: 44px; }

.gentle-suggestion {
    display: none;
    text-align: center;
    margin: 12px 0 4px;
    animation: fadeIn 0.4s ease;
}
.gentle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    cursor: pointer;
    min-height: 44px;
    transition: 0.2s;
}
.gentle-btn:hover { background: var(--bg); color: var(--text); }

/* 📱 44px WCAG 觸控規範 */
.btn-row { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.btn-primary {
    flex: 2; background: var(--warm); color: #fff; border: none;
    padding: 12px 10px; min-height: 46px; border-radius: 40px; font-weight: 500;
    font-size: 1rem; cursor: pointer; transition: 0.2s; min-width: 140px;
}
.btn-primary:hover { opacity: 0.9; transform: scale(0.99); }
.btn-secondary {
    flex: 1; background: transparent; border: 1px solid var(--border);
    color: var(--muted); padding: 12px 10px; min-height: 46px; border-radius: 40px;
    font-size: 0.9rem; cursor: pointer; transition: 0.2s; min-width: 100px;
}
.btn-secondary:hover { background: var(--bg); color: var(--text); }

.toolbar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tool-btn {
    background: transparent; border: none; color: var(--muted);
    font-size: 0.8rem; padding: 6px 10px; min-height: 36px; cursor: pointer; border-radius: 20px;
    display: inline-flex; align-items: center;
}
.tool-btn:hover { text-decoration: underline; }

.footer-card {
    text-align: center; font-size: 0.8rem; color: var(--muted);
    line-height: 1.6; border-top: 1px solid var(--border);
    padding-top: 16px; margin-top: 8px;
}
.footer-link-row { margin-bottom: 6px; }
.link-style { font-size: 0.85rem; text-decoration: underline; }
.warm-text { color: var(--warm); font-weight: 500; }
.disclaimer-text { font-size: 0.75rem; margin-top: 6px; }
.crypto-meta { font-size: 0.65rem; opacity: 0.5; margin-top: 4px; }

/* 彈窗樣式 */
.modal-mask {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    justify-content: center; align-items: center; padding: 20px; z-index: 999;
}
.modal-box {
    background: var(--card); border-radius: var(--radius);
    max-width: 480px; width: 100%; padding: 28px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25); text-align: center;
}
.modal-box h3 { font-weight: 500; margin-bottom: 8px; }
.modal-box p { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
.modal-box.left-align { text-align: left; }
.modal-box.wide-box { max-width: 500px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions button { flex: 1; min-height: 44px; }

.scrollable-box { max-height: 82vh; overflow-y: auto; }
.text-center { text-align: center; margin-bottom: 14px; }
.guide-text { font-size: 0.88rem; line-height: 1.7; color: var(--text); }
.password-field { text-align: center; font-size: 1.1rem; letter-spacing: 2px; }

.rose-text { color: var(--rose); }
.sage-text { color: var(--sage); }
.full-width { width: 100%; }
.modal-top-gap { margin-top: 14px; }

.hotline-box { background: var(--bg); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 0.9rem; }
.hotline-item { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding: 8px 0; }
.hotline-item:last-child { border-bottom: none; }
.hotline-sub { font-size: 0.85rem; color: var(--muted); }
.hotline-link { color: var(--warm); font-weight: bold; text-decoration: none; white-space: nowrap; margin-left: 8px; min-height: 36px; display: inline-flex; align-items: center; }

.grounding-step {
    font-size: 1.05rem; padding: 10px 14px; background: var(--bg);
    border-radius: 12px; margin: 8px 0; color: var(--text); text-align: left;
}
.grounding-step small { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* 浮動提示 Toast */
#gentle-toast {
    display: none; position: fixed; bottom: 32px; left: 50%;
    transform: translateX(-50%); background: var(--card);
    color: var(--text); border: 1px solid var(--border);
    border-radius: 30px; padding: 14px 28px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.28); z-index: 2000;
    font-size: 0.92rem; text-align: center; line-height: 1.5;
    animation: fadeInToast 0.35s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInToast { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 🖨️ 紙本留存專屬排版 */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0;
    }
    .top-bar, .breath-area, .tag-group, .slider-wrap, .tabs, 
    .gentle-suggestion, .btn-row, .toolbar, .footer-card, 
    .modal-mask, #gentle-toast, .skip-link {
        display: none !important;
    }
    .container { max-width: 100%; width: 100%; }
    .card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }
    textarea, input[type="text"] {
        border: none !important;
        background: transparent !important;
        color: #000000 !important;
        padding: 0 !important;
        font-size: 1.1rem !important;
        line-height: 1.8 !important;
        resize: none;
    }
}
