:root {
  --bg: #fbf8f3; --surface: #fff; --text: #1f2a2e; --muted: #5d6b70;
  --brand: #0f766e; --brand-ink: #fff; --accent: #e6f2ef; --line: #e5e0d8;
  --note: #fff7e6; --note-line: #f0c36d; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121816; --surface: #1b2321; --text: #e8eeec; --muted: #9fb0ab;
    --brand: #5fd0c0; --brand-ink: #0b1513; --accent: #1f302d; --line: #2c3835;
    --note: #2a2516; --note-line: #8a6d2b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
a { color: var(--brand); }

.top {
  position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; padding: .6rem 16px;
}
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--text); display: flex; align-items: baseline; gap: .4rem; }
.brand small { font-weight: 500; font-size: .75rem; color: var(--muted); }
.lang-switch {
  margin-left: auto; display: flex; align-items: center; gap: .35rem; text-decoration: none; color: var(--muted);
  font-size: .85rem; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem .2rem .3rem;
}
.lang-switch img { border-radius: 3px; display: block; }
.top nav { order: 3; width: 100%; }
.hero.picker { text-align: center; }
body[data-home=""] .lang-switch, body[data-home=""] .top nav { display: none; }
.flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0 2rem; }
.flag-choice {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem .6rem;
  transition: border-color .15s, transform .15s;
}
a.flag-choice:hover { border-color: var(--brand); transform: translateY(-2px); }
.flag-choice img { width: 96px; height: 64px; border-radius: 6px; box-shadow: 0 1px 4px #0002; }
.flag-choice strong { font-size: 1.05rem; }
.flag-choice span { font-size: .85rem; color: var(--muted); }
.flag-choice.soon { opacity: .55; }
.top nav { display: flex; gap: .25rem; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.top nav a { white-space: nowrap; text-decoration: none; color: var(--muted); padding: .4rem .7rem; border-radius: 999px; font-size: .95rem; }
.top nav a[aria-current=page] { background: var(--accent); color: var(--brand); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.hero h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.2; margin: .5rem 0; }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0 0 1.5rem; }
h2.section { font-size: 1.05rem; color: var(--muted); margin: 1.75rem 0 .75rem; }

.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin: 0 0 1.5rem; }
.card {
  display: flex; flex-direction: column; gap: .3rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card strong { font-size: 1.05rem; }
.card span { color: var(--muted); font-size: .93rem; }
.badge {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px;
  background: var(--note); border: 1px solid var(--note-line); color: var(--text); vertical-align: middle;
}
.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); text-decoration: none; padding: .65rem 1.1rem; border-radius: 10px; font-weight: 600; }

.prose h1 { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.25; margin: .25rem 0; }
.prose h2 { font-size: 1.25rem; margin: 2rem 0 .5rem; }
.meta, .muted { color: var(--muted); font-size: .9rem; }
.note { background: var(--note); border-left: 4px solid var(--note-line); padding: .75rem 1rem; border-radius: 8px; margin: 1.25rem 0; }

.checklist { list-style: none; padding: 0; }
.checklist li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin: .4rem 0; }
.checklist label { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .9rem; cursor: pointer; }
.checklist input { width: 1.3rem; height: 1.3rem; margin-top: .2rem; flex: none; accent-color: var(--brand); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }

.table { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { background: var(--accent); font-size: .9rem; }
td:last-child { font-size: 1.15rem; }

.search span { display: block; font-weight: 600; margin: .75rem 0 .3rem; }
textarea {
  width: 100%; font: inherit; padding: .75rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); resize: vertical;
}
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .9rem 0; }
.tabs button {
  font: inherit; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .35rem .8rem; cursor: pointer;
}
.tabs button[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.terms { display: grid; gap: .5rem; }
.term { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.term .zh { font-size: 1.25rem; font-weight: 700; }
.term .py { color: var(--muted); font-size: .85rem; margin-left: .4rem; }
.term p { margin: .2rem 0 0; }

.shop dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; }
.shop dt { color: var(--muted); }
.shop dd { margin: 0; }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; padding: 0; list-style: none; }
.tags li { background: var(--accent); border-radius: 999px; padding: .15rem .65rem; font-size: .85rem; }

.shop-grid > div { display: flex; }
.shop-grid > div > .card { flex: 1; }
.shop-grid > div[hidden] { display: none; }
#shop-city { font: inherit; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }

.form label { display: block; margin: .7rem 0; }
.form label span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .25rem; }
.form input, .form select {
  width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
.form input:focus, .form select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.form button.btn { border: 0; font: inherit; font-weight: 600; cursor: pointer; margin-top: .3rem; }
.form.row { display: flex; flex-wrap: wrap; gap: 0 .6rem; align-items: flex-end; }
.form.row label { flex: 1 1 160px; }
.form.row .btn { margin-bottom: .7rem; }
button.btn { border: 0; font: inherit; font-weight: 600; cursor: pointer; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem 1rem; margin: 1.5rem 0; }
.panel summary { cursor: pointer; font-weight: 700; padding: .7rem 0; }

.reminders { list-style: none; padding: 0; display: grid; gap: .5rem; }
.reminders li { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.reminders li.soon { border-left-color: var(--note-line); }
.reminders li.late { border-left-color: #d9534f; }
.reminders p { margin: .3rem 0 0; font-size: .93rem; }
.r-head { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.r-when { white-space: nowrap; font-weight: 600; color: var(--brand); font-size: .92rem; }
.late .r-when { color: #d9534f; }
.plain { list-style: none; padding: 0; }
.plain li { padding: .3rem 0; }

.badge.t-tw { background: var(--accent); border-color: var(--brand); }
.badge.t-islam { background: #e8f5e9; border-color: #4caf50; color: #1b5e20; }
.badge.t-id { background: #fdecea; border-color: #e57373; color: #8e1b1b; }
.reminders li[hidden], .term[hidden] { display: none; }
input[type=search] { width: 100%; font: inherit; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }

.stats { font-size: 1.05rem; }
.daily-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; margin: .75rem 0 1rem; text-align: center;
}
.daily-zh { font-size: clamp(1.8rem, 8vw, 2.6rem); font-weight: 800; line-height: 1.3; margin: .3rem 0; }
.daily-py { color: var(--muted); font-size: 1.05rem; margin: 0 0 .6rem; }
.daily-ex { font-size: 1.2rem; font-weight: 600; color: var(--brand); }
.daily-card .actions { justify-content: center; }

.badge.t-halal { background: #e8f5e9; border-color: #4caf50; color: #1b5e20; }
.badge.t-ad { background: #fff3cd; border-color: #d4a017; color: #6b4e00; }
.badge.t-open { background: #e3f2fd; border-color: #64b5f6; color: #0d47a1; }
.badge.t-open.closed { background: var(--surface); border-color: var(--line); color: var(--muted); }
.badge[hidden] { display: none; }
.card .badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.card[hidden] { display: none; }
.btn.ghost { background: var(--surface); color: var(--brand); border: 1px solid var(--brand); }
.filters { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; margin-bottom: 1rem; }
.filters select { font: inherit; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.filters .check { display: flex; gap: .4rem; align-items: center; }

.s-pork, mark.s-pork { background: #fdecea; border-color: #e53935; color: #b71c1c; }
.s-alcohol, mark.s-alcohol { background: #fff3e0; border-color: #fb8c00; color: #8a4b00; }
.s-ask, mark.s-ask { background: #fffde7; border-color: #fbc02d; color: #6d5600; }
.s-ok, mark.s-ok { background: #e8f5e9; border-color: #43a047; color: #1b5e20; }
mark { border-radius: 4px; padding: 0 .15em; border-bottom: 2px solid; font-weight: 700; }
.verdict { border: 2px solid; border-radius: var(--radius); padding: .8rem 1rem; font-weight: 800; font-size: 1.15rem; margin: 1rem 0 .6rem; }
.verdict.s-none { border-color: var(--line); color: var(--muted); }
.menu-marked { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; font-size: 1.2rem; line-height: 2; white-space: pre-wrap; margin-bottom: .8rem; }

.select { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.prayer-list { list-style: none; padding: 0; display: grid; gap: .35rem; }
.prayer-list li { display: flex; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .9rem; font-size: 1.1rem; }
.prayer-list li.past { color: var(--muted); }
.prayer-list li.next { border-color: var(--brand); border-width: 2px; background: var(--accent); }
table.small th, table.small td { font-size: .88rem !important; padding: .45rem .5rem; white-space: nowrap; }
tr.today td { background: var(--accent); font-weight: 700; }
td.iftar { color: var(--brand); font-weight: 700; }
.qibla { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.qibla p { flex: 1 1 200px; margin: 0; }
.mosques li { border-bottom: 1px solid var(--line); padding: .6rem 0; }

.scan-actions .btn { cursor: pointer; }
.scan-preview { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); display: block; margin: .5rem 0; }
.scan-preview[hidden] { display: none; }
.scan-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1rem; }
.scan-head h2 { margin: 0; }
.scan-summary { font-size: 1.1rem; }
.scan-points { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; }
.scan-points dt { color: var(--muted); }
.scan-points dd { margin: 0; font-weight: 600; }
.scan-ask { font-size: 1.25rem; font-weight: 700; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem; }

.calls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.call {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .9rem; text-decoration: none; color: var(--text);
}
.call strong { font-size: 1.6rem; color: #c0392b; line-height: 1.2; }
.call span { font-size: .88rem; color: var(--muted); }
.sos-card { background: #fff; color: #111; border: 3px solid #c0392b; border-radius: var(--radius); padding: 1rem 1.2rem; margin: .5rem 0 1rem; }
.sos-card a { color: #0b5ed7; }
.sos-big { font-size: 1.6rem; font-weight: 800; line-height: 1.4; margin: 0 0 .5rem; }
.sos-card h3 { font-size: 1rem; margin: .8rem 0 .2rem; color: #c0392b; }
.sos-line { font-size: 1.25rem; margin: .1rem 0; }
.sos fieldset { border: 1px solid var(--line); border-radius: 10px; margin: .8rem 0; padding: .3rem .9rem; }
.sos legend { font-weight: 700; padding: 0 .3rem; }
.form label.check { display: flex; gap: .5rem; align-items: center; margin: .35rem 0; font-weight: 400; }
.form label.check input { width: 1.2rem; height: 1.2rem; }
.sos-full {
  position: fixed; inset: 0; z-index: 50; background: #fff; padding: 24px 16px; overflow: auto;
  display: flex; flex-direction: column; justify-content: center;
}
.sos-full[hidden] { display: none; }
.sos-full .sos-card { border: 0; font-size: 1.3em; }
.sos-full .sos-big { font-size: clamp(2rem, 9vw, 3.4rem); }
.sos-full .sos-line { font-size: clamp(1.4rem, 6vw, 2rem); }
@media print {
  body * { visibility: hidden; }
  #sos-card, #sos-card * { visibility: visible; }
  #sos-card { position: absolute; left: 0; top: 0; width: 9cm; font-size: 10pt; }
  #sos-card .speak { display: none; }
}

.speak {
  border: 1px solid var(--line); background: var(--accent); border-radius: 999px; cursor: pointer;
  font-size: .85rem; line-height: 1; padding: .3rem .45rem; vertical-align: middle;
}
.speak:active { transform: scale(.95); }

.foot { border-top: 1px solid var(--line); padding: 1.5rem 16px 2.5rem; color: var(--muted); font-size: .88rem; max-width: 760px; margin: 0 auto; }
.foot a { color: var(--muted); }
