:root {
  --primary: #4f5d2f;
  --primary-dark: #35401f;
  --primary-soft: #eef1e4;
  --accent: #c9a646;
  --accent-soft: #f4ead1;
  --bg: #f8f6ef;
  --paper: #fffdf8;
  --surface: #ffffff;
  --surface-soft: #fbfaf4;
  --text: #2e3326;
  --muted: #6f755f;
  --line: #e6e0d2;
  --shadow-sm: 0 2px 8px rgba(53, 64, 31, .08);
  --shadow-md: 0 10px 30px rgba(53, 64, 31, .18);
  --radius: 18px;
  --appbar-height: calc(144px + env(safe-area-inset-top));
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgba(201, 166, 70, .18), transparent 34%),
    linear-gradient(180deg, #fbfaf4 0%, var(--bg) 42%, #f2ede0 100%);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.appbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  min-height: var(--appbar-height);
  padding: calc(10px + env(safe-area-inset-top)) 16px 14px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(201, 166, 70, .18), transparent 38%),
    linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 10px 22px rgba(53, 64, 31, .24);
}
.appbar::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 1px;
  background: rgba(255, 255, 255, .18);
}
.appbar-main, .mode-switch { max-width: 720px; margin-left: auto; margin-right: auto; }
.appbar-main {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { min-width: 0; display: flex; align-items: center; gap: 12px; }
.brand-mark {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #e0bf68, var(--accent));
  color: #2f321d;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.36), 0 8px 18px rgba(0,0,0,.16);
}
.brand-copy { min-width: 0; }
.appbar-title {
  font-size: 22px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-subtitle { margin-top: 4px; color: rgba(255,255,255,.78); font-size: 13px; font-weight: 700; }
.appbar-menu {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 4px;
}
.mode-switch {
  height: 48px;
  margin-top: 8px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.62);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  box-shadow: inset 0 1px 5px rgba(53,64,31,.18), 0 8px 18px rgba(0,0,0,.14);
}
.mode-btn {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mode-btn.active {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 5px 12px rgba(53,64,31,.24);
}
.mode-btn.active::after { content: ""; width: 6px; height: 6px; margin-left: 8px; border-radius: 50%; background: var(--accent); }
.mode-btn:active, .row:active, .small-btn:active, .back-btn:active { transform: scale(.985); }

.overflow-menu {
  position: absolute;
  top: calc(66px + env(safe-area-inset-top));
  right: max(16px, calc((100vw - 720px) / 2 + 16px));
  width: min(310px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px;
  display: none;
}
.overflow-menu.open { display: block; }
.overflow-menu button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 17px;
  font-weight: 700;
  padding: 14px 16px;
}
.overflow-menu button:active { background: var(--primary-soft); }

.page { min-height: 100vh; max-width: 720px; margin: 0 auto; padding: var(--appbar-height) 0 28px; }
.screen { display: none; }
.screen.active { display: block; }

.search-box {
  margin: 20px 16px 16px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}
.search-icon { color: var(--primary); font-size: 30px; line-height: 1; transform: rotate(-20deg); width: 30px; text-align: center; }
.search-box input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
}
.search-box input::placeholder { color: #9b9b8d; opacity: 1; font-weight: 600; }

.search-box input[type="search"]::-webkit-search-cancel-button,
.search-box input[type="search"]::-webkit-search-decoration,
.search-box input[type="search"]::-webkit-search-results-button,
.search-box input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.search-box input[type="search"]::-ms-clear,
.search-box input[type="search"]::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

.search-box {
  position: relative;
  overflow: visible;
}
.search-box.has-value input { padding-right: 42px; }
.search-clear-btn {
  position: absolute;
  top: 50%;
  right: -10px;
  width: 64px;
  height: 64px;
  border: 6px solid rgba(255,255,255,.98);
  border-radius: 50%;
  background: linear-gradient(145deg, #e6c767, var(--accent));
  color: var(--primary-dark);
  box-shadow: 0 12px 26px rgba(53,64,31,.22);
  font-size: 36px;
  line-height: 1;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transform: translateY(-50%);
}
.search-clear-btn[hidden] { display: none !important; }
.search-clear-btn:active { transform: translateY(-50%) scale(.94); }
.theme-dark .search-clear-btn {
  border-color: var(--dark-surface);
  box-shadow: 0 12px 26px rgba(0,0,0,.34);
}
@media (max-width: 380px) {
  .search-clear-btn { right: -8px; width: 58px; height: 58px; font-size: 32px; border-width: 5px; }
  .search-box.has-value input { padding-right: 38px; }
}

.continue-panel {
  margin: 16px;
  padding: 16px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
}
.continue-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.continue-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.continue-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  padding: 14px;
  border: 1px solid rgba(201,166,70,.34);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(248,239,213,.92), rgba(255,255,255,.94));
  color: var(--primary-dark);
  text-align: left;
  box-shadow: 0 10px 22px rgba(53,64,31,.08);
}
.continue-card strong { font-size: 17px; line-height: 1.1; }
.continue-card span { color: var(--muted); font-size: 13px; font-weight: 800; }
.verse.verse-focus {
  margin: 0 -8px;
  padding: 14px 8px;
  background: linear-gradient(90deg, rgba(201,166,70,.28), rgba(201,166,70,.09));
  border: 1px solid rgba(201,166,70,.42);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(201,166,70,.18);
}
.theme-dark .continue-panel,
.theme-dark .continue-card {
  background: var(--dark-surface);
  border-color: rgba(255,255,255,.12);
}
.theme-dark .verse.verse-focus {
  background: linear-gradient(90deg, rgba(201,166,70,.23), rgba(201,166,70,.07));
  border-color: rgba(201,166,70,.35);
}
@media (max-width: 420px) {
  .continue-list { grid-template-columns: 1fr; }
}

.list { padding: 0 16px 20px; }
.loading, .empty {
  border: 0;
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
  font-size: 17px;
  font-weight: 700;
}
.section-header {
  margin: 18px 0 10px;
  padding: 10px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .2px;
  box-shadow: 0 6px 14px rgba(53,64,31,.15);
}
.section-header::before { content: ""; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--accent); }
.row {
  min-height: 66px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  color: var(--text);
  margin: 0 0 10px;
  padding: 13px 14px 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.row:hover { box-shadow: 0 5px 16px rgba(53,64,31,.12); }
.row-title { display: block; font-size: 20px; font-weight: 850; line-height: 1.24; letter-spacing: -.2px; }
.row-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.3; font-weight: 700; }
.chevron {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin-left: 12px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  line-height: 28px;
  font-weight: 800;
}

.sub-title-row, .hino-top {
  position: relative;
  padding: 24px 58px 14px;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.sub-title-row h1, .hino-top h1 { margin: 0; color: var(--text); font-size: 25px; line-height: 1.2; font-weight: 900; letter-spacing: -.3px; }
.back-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.9);
  color: var(--primary-dark);
  font-size: 44px;
  line-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.sub-title-row .back-btn, .hino-top .back-btn.absolute { position: absolute; left: 14px; top: 20px; }
.chapter-bar {
  margin: 0 16px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.chapter-footer-nav {
  margin: 0 16px 30px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.chapter-bar select {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}
.small-btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
  min-height: 52px;
  text-align: center;
}
.small-btn:disabled { opacity: .42; }
@media (max-width: 420px) {
  .chapter-bar { grid-template-columns: 1fr; }
  .chapter-bar select { width: 100%; order: -1; }
  .chapter-footer-nav { grid-template-columns: 1fr; }
}

.text-card, .lyrics-card {
  margin: 0 16px 30px;
  padding: 18px 18px 26px;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
}
.verse {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(53,64,31,.08);
}
.verse:last-child { border-bottom: 0; }
.verse-number {
  color: var(--accent);
  font-size: 16px;
  line-height: 1.65;
  font-weight: 900;
}
.verse-text { font-size: 20px; line-height: 1.62; }
.result-ref { display: block; color: var(--primary); font-size: 14px; font-weight: 900; margin-bottom: 5px; }
.result-text { display: block; color: var(--text); font-size: 16px; line-height: 1.45; }
.result-count {
  margin: 0 0 10px;
  padding: 12px 14px;
  color: var(--muted);
  background: var(--accent-soft);
  border: 1px solid rgba(201,166,70,.32);
  border-radius: 16px;
  font-size: 14px;
  font-weight: 800;
}
.hino-stanza {
  position: relative;
  margin: 0 0 28px;
  padding-left: 42px;
  font-size: 22px;
  line-height: 1.44;
  white-space: pre-line;
}
.hino-stanza-number {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary);
  font-size: 14px;
  line-height: 1;
  font-weight: 900;
}
.hino-chorus {
  margin: 0 0 28px 42px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 16px;
  background: var(--accent-soft);
  color: #36351f;
  font-size: 21px;
  line-height: 1.43;
  white-space: pre-line;
}

.toast {
  position: fixed;
  left: max(18px, calc((100vw - 720px) / 2 + 18px));
  right: max(18px, calc((100vw - 720px) / 2 + 18px));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 80;
  background: rgba(53,64,31,.96);
  color: #fff;
  padding: 14px 16px;
  border-radius: 16px;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  box-shadow: var(--shadow-md);
  transform: translateY(120%);
  opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 380px) {
  :root { --appbar-height: calc(138px + env(safe-area-inset-top)); }
  .appbar { padding-left: 12px; padding-right: 12px; }
  .brand-mark { width: 42px; height: 42px; flex-basis: 42px; border-radius: 14px; }
  .appbar-title { font-size: 20px; }
  .appbar-subtitle { font-size: 12px; }
  .mode-btn { font-size: 17px; }
  .search-box input { font-size: 17px; }
  .row-title { font-size: 18px; }
  .hino-stanza, .hino-chorus { font-size: 20px; }
  .hino-chorus { margin-left: 24px; }
  .hino-stanza { padding-left: 36px; }
}
