:root {
    --sun: #f59e0b;
    --sun-deep: #d97706;
    --sun-soft: #fef3c7;
    --ink: #292524;
    --ink-soft: #57534e;
    --muted: #8a817a;
    --bg: #fffbf5;
    --card: #ffffff;
    --line: #f0e6d8;
    --ok: #16a34a;
    --radius: 18px;
    --shadow: 0 2px 10px rgba(120, 80, 20, 0.08);
    --tabbar-h: 68px;
    font-size: 17px;
}
html[data-font="large"] { font-size: 19.5px; }
html[data-font="xlarge"] { font-size: 22px; }

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f5f0ea;
        --ink-soft: #d6cfc6;
        --muted: #a8a097;
        --bg: #1c1917;
        --card: #292524;
        --line: #3a3430;
        --sun-soft: #3d2f12;
        --shadow: none;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    word-break: keep-all;
    -webkit-text-size-adjust: 100%;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 상단 바 ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
    min-width: 44px; height: 44px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 700;
}
.icon-btn small { font-size: 0.7em; margin-left: 1px; }

main { max-width: 680px; margin: 0 auto; padding: 16px; }

/* ---------- 홈 ---------- */
.hero {
    border-radius: var(--radius);
    padding: 28px 22px;
    margin-bottom: 14px;
    color: #422006;
    background: radial-gradient(circle at 88% 10%, #fde68a 0, #fcd34d 22%, transparent 23%),
                linear-gradient(135deg, #fff7d6 0%, #fde3a7 55%, #fbbf77 100%);
}
.hero-date { font-size: 0.85rem; opacity: 0.8; }
.hero h1 { font-size: 1.8rem; line-height: 1.3; margin: 4px 0; }
.hero-slogan { font-size: 0.95rem; }

.card {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 14px;
}
.card-kicker { font-size: 0.85rem; font-weight: 700; color: var(--sun-deep); margin-bottom: 8px; }
.card-kicker + .card-kicker, ol + .card-kicker { margin-top: 14px; }

.prayer-card { background: linear-gradient(135deg, var(--card), var(--sun-soft)); }
.prayer-times { display: flex; gap: 10px; margin: 6px 0 8px; }
.ptime {
    flex: 1; text-align: center; padding: 12px 6px; border-radius: 14px;
    background: var(--card); border: 2px solid var(--sun);
}
.ptime strong { display: block; font-size: 1.35rem; }
.ptime span { font-size: 0.8rem; color: var(--muted); }
.prayer-next { font-size: 0.9rem; color: var(--ink-soft); text-align: center; }

.verse-card { border-left: 5px solid var(--sun); }
.verse-text { font-size: 1.1rem; font-weight: 600; }
.verse-ref { color: var(--sun-deep); font-weight: 600; font-size: 0.9rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; min-height: 120px;
    display: flex; flex-direction: column; gap: 2px;
}
.tile-icon { font-size: 1.7rem; }
.tile strong { font-size: 1.05rem; }
.tile span:last-child { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.plain-list { list-style: none; }
.plain-list li { padding: 6px 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: none; }

/* ---------- 공통 ---------- */
.view-title { font-size: 1.5rem; margin: 4px 0 14px; }
.section-title { font-size: 1.1rem; margin: 18px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 50px; padding: 10px 18px;
    border-radius: 14px; border: 1px solid var(--line);
    background: var(--card); font-weight: 600; cursor: pointer; text-align: center;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--sun); border-color: var(--sun); color: #3b1d00; }
.btn-primary:active { background: var(--sun-deep); }
.btn.block { display: flex; width: 100%; }
.btn-col { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }

.prayer-list { padding-left: 1.4em; }
.prayer-list li { padding: 4px 0; }

/* ---------- 성경 ---------- */
.plan-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
    padding: 8px 14px; min-height: 44px; border-radius: 999px; cursor: pointer;
    border: 2px solid var(--sun); background: var(--card); font-weight: 600;
}
.chip.done { background: var(--sun); color: #3b1d00; }
.progress { height: 10px; border-radius: 99px; background: var(--sun-soft); overflow: hidden; }
.progress-bar { height: 100%; background: var(--sun); width: 0; transition: width .3s; }
.plan-card .muted { margin-top: 6px; }

.bible-controls { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-bottom: 10px; }
select, input, textarea {
    width: 100%; min-height: 50px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
textarea { resize: vertical; line-height: 1.5; }
.passage-title { font-size: 1.2rem; margin: 6px 0 10px; }

.reader {
    background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden;
}
.text-reader, .passage-text { padding: 18px; line-height: 1.85; font-size: 1.05rem; }
.text-reader p, .passage-text p { margin-bottom: 6px; }
.text-reader sup, .passage-text sup { color: var(--sun-deep); font-weight: 700; font-size: 0.7em; margin-right: 2px; }
.passage-text { margin: 10px 0; background: var(--sun-soft); border: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }

/* ---------- 설교 · QT ---------- */
.sermon-title { font-size: 1.3rem; line-height: 1.35; }
.video { position: relative; padding-top: 56.25%; margin: 12px 0; border-radius: 14px; overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-empty {
    margin: 12px 0; padding: 36px 12px; text-align: center; border-radius: 14px;
    background: var(--sun-soft); color: var(--ink-soft);
}
.passage { margin: 10px 0; }
.passage summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.link-list { list-style: none; }
.link-list button {
    width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 14px 16px; margin-bottom: 8px; min-height: 54px; cursor: pointer;
    border: 1px solid var(--line); border-radius: 14px; background: var(--card);
}
.link-list button.active { border-color: var(--sun); background: var(--sun-soft); }
.link-list small { color: var(--muted); white-space: nowrap; }

.field { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 12px; }
.field textarea { margin-top: 6px; font-weight: 400; }

/* ---------- 기도 ---------- */
.alarm-card { background: linear-gradient(135deg, var(--card), var(--sun-soft)); }
.alarm-card .muted { text-align: center; margin-bottom: 12px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 10px; }
.inline-form .btn { flex: none; }
.my-prayers { list-style: none; }
.my-prayers li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.my-prayers li:first-child { border-top: 0; }
.my-prayers li span { flex: 1; }
.my-prayers li.answered span { color: var(--muted); text-decoration: line-through; }
.my-prayers button { background: none; border: 0; min-width: 40px; min-height: 40px; cursor: pointer; font-size: 1.1rem; }
.my-prayers .del { color: var(--muted); }

/* ---------- 교회 ---------- */
.notice { padding: 10px 0; border-top: 1px solid var(--line); }
.notice:first-child { border-top: 0; padding-top: 0; }
.notice small { display: block; color: var(--muted); }
.event-list { list-style: none; }
.event-list li { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.event-list small { display: block; color: var(--muted); }
.event-date {
    flex: none; width: 54px; height: 54px; border-radius: 14px; background: var(--sun-soft);
    display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.event-date strong { font-size: 1.2rem; }
.event-date span { font-size: 0.75rem; }
.worship-table { width: 100%; border-collapse: collapse; }
.worship-table th, .worship-table td { text-align: left; padding: 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.worship-table tr:first-child th, .worship-table tr:first-child td { border-top: 0; }
.worship-table th { width: 42%; font-weight: 600; }

/* ---------- 하단 탭 ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 0.78rem; color: var(--muted); font-weight: 600;
}
.tabbar a span { font-size: 1.4rem; line-height: 1.2; filter: grayscale(1); opacity: 0.7; }
.tabbar a.active { color: var(--sun-deep); }
.tabbar a.active span { filter: none; opacity: 1; }

/* ---------- 기도 시간 팝업 ---------- */
.overlay {
    position: fixed; inset: 0; z-index: 50; padding: 20px;
    background: rgba(40, 25, 5, 0.55);
    display: flex; align-items: center; justify-content: center;
}
.overlay-box {
    width: 100%; max-width: 420px; max-height: 90vh; overflow: auto;
    background: var(--card); border-radius: 24px; padding: 26px 22px; text-align: center;
}
.overlay-icon { font-size: 3rem; }
.overlay-box h2 { margin: 6px 0; }
.overlay-box .prayer-list { text-align: left; margin: 14px 0; }
.overlay-box .btn { margin-top: 8px; }

/* ---------- 번역본 선택 · 영어 본문 ---------- */
.version-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.segmented { flex: 1; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; border-radius: 14px; background: var(--sun-soft); }
.segmented button { min-height: 42px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.lang-en { font-family: Georgia, 'Times New Roman', serif; line-height: 1.75; }
.lang-en sup { font-family: -apple-system, sans-serif; }
.en-toggle { display: inline-block; margin: 2px 0 10px; padding: 10px 14px; min-height: 44px; border: 1px solid var(--sun); border-radius: 12px; background: transparent; color: var(--sun-deep); font: inherit; font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.en-toggle.open { background: var(--sun); color: #fff; }
.passage-en { margin-bottom: 12px; }

/* ---------- 영어 듣기 ---------- */
.listen-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.listen-bar #listenBtn { grid-column: 1 / -1; }
#voiceTip { margin: -4px 0 10px; }
.text-reader p { cursor: pointer; border-radius: 8px; padding: 2px 6px; margin-left: -6px; margin-right: -6px; transition: background .2s; }
.text-reader p.speaking { background: var(--sun-soft); }
.listen-box { margin-bottom: 10px; }
.listen-box .segmented { margin-bottom: 10px; }
.audio-label { font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
#kjvAudio { width: 100%; height: 48px; }

/* ---------- 설교 요약 ---------- */
.sermon-text { margin: 10px 0; line-height: 1.8; }
.sermon-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.sermon-section h4 { font-size: 1.08rem; color: var(--sun-deep); margin-bottom: 6px; }
.sermon-conclusion { margin-top: 18px; padding: 4px 14px; border-left: 4px solid var(--sun); background: var(--sun-soft); border-radius: 8px; }
.qt-intro { margin-bottom: 14px; }
