/* 中繼站手機頁：深綠金品牌、行動優先、大觸控目標 */

:root {
    --bg: #0f1613;
    --panel: #1a231d;
    --panel-soft: #212c25;
    --ink: #e8e6dc;
    --muted: #9aa89d;
    --gold: #d4b04a;
    --green: #5fae8a;
    --red: #d98a75;
    --line: #2c372f;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "PingFang TC", "Noto Sans TC", sans-serif;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(15, 22, 19, 0.95);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
}

/* 跟網站頁首同一個「O AI」圖（static/logo-mark.svg 由 scripts/make-pwa-icons.php 從 public/images 複製來） */
.brand-mark {
    display: block;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.logout-form { display: flex; align-items: center; gap: 10px; margin: 0; }
.whoami { color: var(--muted); font-size: 13px; }

.btn-ghost {
    background: none;
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

/* 登入 */
.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 26px 22px;
    margin-top: 8vh;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.hint { color: var(--muted); font-size: 13px; }

label { display: block; font-size: 14px; margin: 14px 0 4px; color: var(--muted); }

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 13px 14px;
    font-size: 17px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--ink);
}

input:focus { outline: 2px solid rgba(212, 176, 74, 0.5); border-color: var(--gold); }

.btn-primary {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    font-size: 17px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #c9a227, #8f6f1c);
    color: #171204;
}

.alert {
    margin: 14px 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(217, 138, 117, 0.14);
    border: 1px solid rgba(217, 138, 117, 0.5);
    color: var(--red);
    font-size: 14px;
}

/* 範本觸發入口 */
.template-entry {
    display: block;
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.22), rgba(143, 111, 28, 0.12));
    border: 1px solid rgba(212, 176, 74, 0.5);
    color: var(--gold);
    font-weight: 700;
    text-decoration: none;
    font-size: 15px;
}

.template-entry.is-free {
    background: linear-gradient(135deg, rgba(95, 174, 138, 0.18), rgba(44, 110, 79, 0.1));
    border-color: rgba(95, 174, 138, 0.5);
    color: var(--green);
    margin-top: 8px;
}

.alert-context {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(217, 138, 117, 0.1);
    border: 1px solid rgba(217, 138, 117, 0.4);
    font-size: 14px;
}
.alert-context-title { font-weight: 700; color: var(--red); margin-bottom: 4px; }
.alert-context-meta { color: var(--muted); font-size: 12.5px; font-family: ui-monospace, Menlo, monospace; margin-top: 4px; }

.push-toggle {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px dashed var(--line);
    color: var(--muted);
    font-size: 14px;
    text-align: left;
}
.push-toggle[data-subscribed="1"] { color: var(--green); border-color: rgba(95, 174, 138, 0.5); }

.mobile-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.mobile-nav a { color: var(--gold); font-size: 16px; text-decoration: none; }
.mobile-nav .push-toggle { flex: 1 1 100%; margin-top: 0; font-size: 16px; cursor: pointer; }
.push-toggle:disabled { cursor: default; opacity: 0.7; }
.notification-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.notification-heading h1 { font-size: 22px; margin: 12px 0; }
.notification-heading button { font-size: 16px; }
.notification-list { list-style: none; padding: 0; }
.notification-list .case-card { overflow-wrap: anywhere; }
.notification-title { margin: 0; font-size: 17px; font-weight: 700; }
.notification-body { white-space: pre-wrap; margin: 8px 0; font-size: 16px; }
.notification-time { color: var(--muted); font-size: 14px; }
.notification-link { color: var(--gold); display: inline-block; padding: 8px 0; }
[hidden] { display: none !important; }

/* 自由設定頁 */
.free-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
    min-height: 34px;
}

.free-chip {
    border: 1px solid rgba(212, 176, 74, 0.6);
    background: rgba(212, 176, 74, 0.14);
    color: var(--gold);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    font-family: ui-monospace, Menlo, monospace;
}

.free-none { color: var(--muted); font-size: 13px; }

.free-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 40vh;
    overflow-y: auto;
    margin-bottom: 8px;
}

.free-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    text-align: left;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--ink);
}

.free-item .row-name { color: var(--muted); font-size: 12.5px; text-align: right; }

/* 案件清單 */
.section-title {
    font-size: 14px;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin: 22px 0 10px;
}
.section-title .count { color: var(--gold); }

.empty {
    background: var(--panel);
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.case-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    color: var(--ink);
    text-decoration: none;
}

.case-card.is-active { border-left-color: #6ea8c9; }
.case-card.is-final { border-left-color: var(--line); opacity: 0.85; }
.case-card.st-executed { border-left-color: var(--green); }
.case-card.st-failed { border-left-color: var(--red); }

.case-title { font-weight: 700; font-size: 15.5px; }
.case-meta, .case-status { color: var(--muted); font-size: 13px; margin-top: 4px; }
.case-error { color: var(--red); font-size: 13px; margin-top: 6px; }
.case-cta { color: var(--gold); font-size: 13px; margin-top: 8px; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    color: var(--muted);
}
.chip.is-gold { color: var(--gold); border-color: rgba(212, 176, 74, 0.5); }

/* 案件明細 */
.back { color: var(--muted); text-decoration: none; font-size: 14px; }

.detail-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    margin-top: 10px;
}

.detail-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.detail-head h1 { font-size: 18px; margin: 0; }

.status-pill {
    font-size: 12px;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}
.status-pill.st-open { color: var(--gold); border-color: rgba(212, 176, 74, 0.5); }
.status-pill.st-executed { color: var(--green); border-color: rgba(95, 174, 138, 0.5); }
.status-pill.st-failed, .status-pill.st-rejected { color: var(--red); border-color: rgba(217, 138, 117, 0.5); }

.detail-meta { color: var(--muted); font-size: 14px; margin: 10px 0; }

.sub-title { font-size: 13px; color: var(--muted); margin: 16px 0 8px; letter-spacing: 0.06em; }

.detail-rows { display: flex; flex-direction: column; gap: 8px; }

.detail-row {
    display: flex;
    gap: 10px;
    background: var(--panel-soft);
    border-radius: 10px;
    padding: 10px 12px;
    align-items: flex-start;
}

.action-tag {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    margin-top: 2px;
}
.a-new { background: rgba(95, 174, 138, 0.18); color: var(--green); }
.a-modify { background: rgba(212, 176, 74, 0.18); color: var(--gold); }
.a-delete { background: rgba(217, 138, 117, 0.18); color: var(--red); }

.row-code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; font-weight: 600; }
.row-name { font-size: 13px; color: var(--muted); }
.row-window { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

/* 決定表單 */
.decide-form { margin-top: 18px; }
.decide-form input[name="totp"] {
    font-size: 26px;
    letter-spacing: 0.4em;
    text-align: center;
    font-family: ui-monospace, Menlo, monospace;
}

.decide-buttons { display: flex; gap: 10px; margin-top: 16px; }

.btn-approve, .btn-reject {
    flex: 1;
    padding: 15px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
}
.btn-approve { background: linear-gradient(135deg, #2c6e4f, #1f5038); color: #e8f4ee; }
.btn-reject { background: var(--panel-soft); border: 1px solid rgba(217, 138, 117, 0.6); color: var(--red); }

.progress-note {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(110, 168, 201, 0.12);
    border: 1px solid rgba(110, 168, 201, 0.4);
    color: #a8cde3;
    font-size: 14px;
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(110, 168, 201, 0.3);
    border-top-color: #a8cde3;
    animation: spin 0.9s linear infinite;
    flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.result-note {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14.5px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
}
.result-note.st-executed { border-color: rgba(95, 174, 138, 0.5); color: var(--green); }
.result-note.st-failed { border-color: rgba(217, 138, 117, 0.5); color: var(--red); }
[hidden] { display: none !important; }
.pair-value { overflow-wrap: anywhere; }
.pair-code { font-family: monospace; font-size: 1.6rem; letter-spacing: .15em; margin-block: .6rem 1rem; }
.pair-restart-link { background: none; border: 0; padding: 4px 0; color: var(--muted); font: inherit; font-size: .875rem; text-decoration: underline; cursor: pointer; }
.pair-restart-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

/* ===== 2026-10-24 改版 A：深藍配色、下一步卡片、底部分頁（跟內網 /relay 同一套顏色） ===== */
:root {
    --bg: #E9EEF4; --panel: #FFFFFF; --panel-soft: #F5F7FA; --ink: #1E293B; --muted: #5B6474;
    --gold: #C2410C; --green: #1E7A4F; --red: #B3261E; --line: #CFD8E3;
    --nav: #13233B; --acc: #E58A2E;
}
html, body { font-size: 16px; }
.topbar { background: var(--nav); border-bottom: 3px solid var(--acc); color: #fff; }
.brand, .brand span { color: #fff; }
.whoami { color: #C9D3E3; font-size: 14px; }
.topbar .btn-ghost { color: #fff; border-color: #5B7092; background: transparent; }
.wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.hello { font-size: 22px; margin: 4px 0 12px; color: var(--nav); }
.hint { font-size: 14px; }
label { color: var(--nav); font-weight: 700; font-size: 15px; }
input[type="text"], input[type="password"] { background: #fff !important; color: var(--ink) !important; border: 1px solid #AEB8C4 !important; }
input:focus { outline: 2px solid rgba(229, 138, 46, .45); border-color: var(--acc) !important; }
.btn-primary { display: block; width: 100%; text-align: center; text-decoration: none; border: 1px solid #B45F15 !important; color: #fff !important; background: linear-gradient(#F4A256, #D9741F) !important; border-radius: 10px; padding: 13px 14px; font-size: 16px; font-weight: 800; }
.btn-primary:disabled { opacity: .6; }
.btn-ghost { border: 1px solid #9AA6B6; background: #fff; color: var(--nav); border-radius: 8px; padding: 6px 12px; font-size: 14px; font-weight: 700; }
.login-card, .detail-card, .case-card, .empty, .notification-list .case-card { background: #fff !important; border: 1px solid var(--line) !important; color: var(--ink); }
.case-card { border-left: 4px solid var(--line) !important; }
.case-card.is-open { border-left-color: var(--acc) !important; }
.case-card.is-active { border-left-color: #2563A8 !important; }
.case-card.st-executed { border-left-color: var(--green) !important; }
.case-card.st-failed { border-left-color: var(--red) !important; }
.case-title { color: var(--nav); font-size: 16px; }
.case-meta, .case-status, .case-error, .case-cta, .detail-meta, .row-name { font-size: 14px; }
.section-title { color: var(--muted); font-size: 15px; }
.chip { background: #EEF2F6 !important; color: var(--ink) !important; border: 1px solid #D3DAE2 !important; font-size: 14px; }
.chip.is-gold { background: #FFF1D6 !important; color: #9A4E0A !important; border-color: #E9B26C !important; }
.status-pill { background: #fff; font-size: 14px; }
.alert { background: #FBEDEC !important; color: var(--red) !important; border: 1px solid #D9A7A3 !important; }
.alert-context { background: #FFF8EC !important; border: 1px solid #E9B26C !important; }
.detail-row { background: var(--panel-soft) !important; border: 1px solid #E1E6EC !important; }
.btn-approve { background: linear-gradient(#F4A256, #D9741F) !important; color: #fff !important; border: 1px solid #B45F15 !important; font-weight: 800; }
.btn-reject { background: #fff !important; color: var(--red) !important; border: 1px solid #D9A7A3 !important; }
.progress-note, .result-note { background: #fff !important; color: var(--ink); border: 1px solid var(--line) !important; }
.result-note.st-executed { color: var(--green); border-color: #9CCFB3 !important; }
.result-note.st-failed { color: var(--red); border-color: #D9A7A3 !important; }
.template-entry { background: #fff !important; color: var(--nav) !important; border: 1px solid var(--line) !important; }
.back { color: #1D4E9A; font-weight: 700; font-size: 15px; }
.free-item { background: #fff !important; color: var(--ink); border-color: var(--line) !important; }
.free-chip { background: #FFF1D6 !important; color: #9A4E0A !important; border-color: #E9B26C !important; }
.free-list { background: #fff !important; border-color: var(--line) !important; }
.notification-link, .mr-page a { color: #1D4E9A; }

.will { margin: 10px 0; padding: 10px 12px; border: 1px solid #D3DAE2; border-radius: 10px; background: var(--panel-soft); color: var(--muted); font-size: 14px; }
.will b { color: var(--nav); }
.will ol { margin: 4px 0; padding-left: 20px; }
.next-card { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; padding: 14px; border: 2px solid var(--acc); border-radius: 14px; background: #fff; box-shadow: 0 4px 12px rgba(229, 138, 46, .18); }
.next-card.is-calm { border-color: var(--green); box-shadow: none; }
.next-card h2 { margin: 0; font-size: 19px; color: var(--nav); }
.next-card p { margin: 0; color: var(--muted); font-size: 15px; }
.next-label { font-size: 13px; font-weight: 800; letter-spacing: .04em; color: var(--gold); }
.next-card.is-calm .next-label { color: var(--green); }
.menu-card { margin-bottom: 16px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #E1E6EC; color: var(--muted); text-decoration: none; }
.menu-item:last-child { border-bottom: 0; }
.menu-item i { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; font-style: normal; color: var(--nav); }
.menu-item i .ico { width: 32px; height: 32px; margin: 0; vertical-align: 0; stroke-width: 1.6; }
.menu-item div { flex: 1; min-width: 0; }
.menu-item b { display: block; color: var(--nav); font-size: 16px; }
.menu-item span { font-size: 14px; color: var(--muted); }
/* 線條圖示（relay/icons.py）：內頁是深藍線條墊淡橘圓，底部導覽列是單色線條 */
.ico { width: 1.15em; height: 1.15em; vertical-align: -.2em; margin-right: 6px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico-blob { fill: #FBDDBB; stroke: none; }
/* 底部導覽列：跟頁首同一塊深藍，上緣橘線；選中的分頁圖示墊黃銅膠囊 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; border-top: 3px solid var(--acc); background: var(--nav); padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: #A9B7CB; font-size: 13px; font-weight: 800; text-decoration: none; }
.tabbar a i { display: grid; place-items: center; width: 58px; height: 30px; border-radius: 999px; font-style: normal; }
.tabbar a .ico { width: 23px; height: 23px; margin: 0; vertical-align: 0; }
.tabbar a.on { color: #fff; }
.tabbar a.on i { background: #F2C572; color: var(--nav); }
.tabbar a.on .ico { stroke-width: 2; }
.foot { font-size: 14px; }
