@font-face {
  font-family: Vazirmatn;
  src: url("/assets/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --forest: #123c31;
  --forest-deep: #092c24;
  --coral: #df654b;
  --saffron: #eaae3b;
  --paper: #f7f2e8;
  --paper-deep: #eee5d6;
  --ink: #1f2523;
  --muted: #68716d;
  --line: #d9d4c9;
  --white: #fffdf8;
  --radius: 8px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --forest: #3f8b70;
  --forest-deep: #081c18;
  --coral: #ee8068;
  --saffron: #f0bd55;
  --paper: #151b19;
  --paper-deep: #252d2a;
  --ink: #edf1ee;
  --muted: #a9b3ae;
  --line: #39423e;
  --white: #1d2421;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: #e7e9e4; color: var(--ink); font-family: Vazirmatn, Tahoma, sans-serif; letter-spacing: 0; }
:root[data-theme="dark"] body { background: #101513; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); background: var(--paper); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 18px 20px; color: #fff; background: var(--forest-deep); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; padding: 0 8px 34px; }
.brand-mark { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; color: var(--forest-deep); background: var(--saffron); font-size: 21px; font-weight: 900; border-radius: 6px 6px 6px 2px; box-shadow: inset -4px 0 rgba(255,255,255,.24); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; }
.brand small { margin-top: 2px; color: #a9beb6; font-size: 11px; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 13px; border: 0; border-radius: 6px; color: #b8c8c2; background: transparent; text-align: right; }
.nav-item span { width: 20px; font-size: 20px; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.09); }
.nav-item.active { box-shadow: inset -3px 0 var(--coral); }
.sidebar-note { margin: auto 12px; padding: 18px 0; color: #d6dfdb; font-family: Georgia, serif; font-size: 17px; line-height: 1.8; }
.note-line { display: block; width: 34px; height: 3px; background: var(--coral); }
.settings-button { margin-top: 10px; }
.main-content { min-width: 0; background: var(--paper); }
.topbar { height: 88px; padding: 0 clamp(24px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar-tools { display: flex; align-items: center; gap: 9px; }
.today-label { display: flex; align-items: baseline; gap: 16px; }
.today-label span { color: var(--muted); font-size: 13px; }
.today-label strong { font-size: 16px; }
.avatar { width: 38px; height: 38px; border: 1px solid var(--forest); border-radius: 50%; color: #fff; background: var(--forest); font-weight: 800; }
.mobile-brand { display: none; }
.view { display: none; padding: clamp(28px, 5vw, 68px) clamp(24px, 5vw, 72px) 72px; }
.view.active { display: block; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: stretch; }
.continue-band { min-height: 420px; display: grid; grid-template-columns: minmax(220px, 34%) minmax(0, 1fr); overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.cover-wrap { position: relative; min-height: 420px; overflow: hidden; background: var(--forest); }
.cover-wrap::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(4,25,20,.08), rgba(4,25,20,.56)); }
.cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-type { position: absolute; z-index: 1; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 28px 24px; color: white; text-shadow: 0 1px 12px rgba(0,0,0,.28); }
.cover-type small { font-size: 12px; }
.cover-type strong { font-family: Vazirmatn, Tahoma, sans-serif; font-size: clamp(28px, 3.2vw, 46px); line-height: 1.35; }
.continue-copy { display: flex; flex-direction: column; justify-content: center; padding: clamp(28px, 4vw, 58px); }
.eyebrow { display: block; margin-bottom: 10px; color: var(--coral); font-size: 12px; font-weight: 800; }
h1, h2, p { margin-top: 0; }
.continue-copy h1 { margin-bottom: 14px; font-size: clamp(30px, 4vw, 52px); line-height: 1.25; }
.continue-copy p { max-width: 560px; color: var(--muted); line-height: 1.95; }
.book-meta { display: flex; gap: 22px; margin: 16px 0 12px; color: var(--muted); font-size: 13px; }
.book-meta span::before { content: "•"; margin-left: 7px; color: var(--coral); }
.progress-track, .reader-progress { height: 4px; overflow: hidden; background: var(--paper-deep); }
.progress-track span, .reader-progress span { display: block; height: 100%; width: 0; background: var(--coral); transition: width .35s ease; }
.continue-actions { display: flex; align-items: center; gap: 14px; margin-top: 26px; flex-wrap: wrap; }
.primary-button, .quiet-button, .text-button { border: 0; }
.primary-button { min-height: 45px; padding: 0 20px; border-radius: 5px; color: #fff; background: var(--forest); font-weight: 800; }
.primary-button:hover { background: var(--forest-deep); }
.primary-button span { margin-right: 20px; font-size: 19px; }
.quiet-button, .text-button { padding: 10px 6px; color: var(--forest); background: transparent; font-weight: 700; }
.quiet-button:hover, .text-button:hover { color: var(--coral); }
.daily-panel { padding: 26px; color: #fff; background: var(--coral); border-radius: var(--radius); }
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; }
.panel-heading span { font-size: 13px; opacity: .85; }
.panel-heading strong { font-size: 20px; }
.week-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 34px 0 26px; direction: rtl; }
.day-dot { display: grid; gap: 8px; justify-items: center; font-size: 10px; }
.day-dot i { width: 22px; height: 32px; border: 1px solid rgba(255,255,255,.5); border-radius: 3px; background: transparent; }
.day-dot.done i { border-color: var(--saffron); background: var(--saffron); box-shadow: inset 0 -7px rgba(255,255,255,.17); }
.daily-panel p { margin: 0; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.25); line-height: 1.9; font-size: 14px; }
.section-block { margin-top: 56px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 25px; }
.book-row, .library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.book-card { min-width: 0; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 16px; padding: 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.book-card:hover { border-color: #aeb8b2; transform: translateY(-2px); transition: .2s ease; }
.mini-cover { position: relative; height: 132px; overflow: hidden; border-radius: 3px; background: var(--forest); box-shadow: -5px 5px 0 #d8d2c7; }
.mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.mini-cover.coral { background: linear-gradient(145deg, #db684f 0 54%, #f0b63d 54%); }
.mini-cover.ink { background: linear-gradient(30deg, #202d3a 0 48%, #78948b 48% 64%, #f0e5d4 64%); }
.mini-cover span { position: absolute; inset: auto 9px 10px; color: #fff; font-weight: 800; line-height: 1.45; text-shadow: 0 1px 5px rgba(0,0,0,.4); }
.book-card-copy { min-width: 0; display: flex; flex-direction: column; }
.book-card small { color: var(--coral); }
.book-card h3 { margin: 8px 0; font-size: 17px; line-height: 1.5; }
.book-card p { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--muted); font-size: 12px; line-height: 1.8; }
.book-card button { margin-top: auto; align-self: start; }
.page-heading { max-width: 700px; margin-bottom: 38px; }
.page-heading h1 { font-size: clamp(32px, 5vw, 56px); margin-bottom: 12px; }
.page-heading p { color: var(--muted); line-height: 1.9; }
.library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.library-grid .book-card { grid-template-columns: 132px 1fr; padding: 22px; }
.library-grid .mini-cover { height: 188px; }
.progress-layout { max-width: 900px; }
.stat-band { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); }
.stat-band div { padding: 32px; text-align: center; border-left: 1px solid var(--line); }
.stat-band div:last-child { border-left: 0; }
.stat-band span, .stat-band small { display: block; }
.stat-band span { color: var(--forest); font-size: 38px; font-weight: 900; }
.stat-band small { margin-top: 5px; color: var(--muted); }
.calendar-panel { margin-top: 44px; }
.calendar-panel .section-heading span { color: var(--muted); font-size: 12px; }
.calendar-grid { display: grid; grid-template-columns: repeat(14, 1fr); gap: 8px; direction: ltr; }
.calendar-day { aspect-ratio: 1; border: 1px solid var(--line); background: var(--white); border-radius: 3px; }
.calendar-day.done { border-color: var(--forest); background: var(--forest); box-shadow: inset 0 -7px rgba(255,255,255,.13); }
.calendar-day.today { outline: 2px solid var(--coral); outline-offset: 2px; }
.reader-view { position: fixed; z-index: 20; inset: 0; display: none; overflow: auto; background: #dad9d1; }
:root[data-theme="dark"] .reader-view { background: #0e1412; }
.reader-view.open { display: block; }
.reader-toolbar { position: sticky; z-index: 2; top: 0; height: 72px; display: grid; grid-template-columns: 120px minmax(0,1fr) 120px; align-items: center; padding: 0 24px; background: rgba(247,242,232,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
:root[data-theme="dark"] .reader-toolbar { background: rgba(21,27,25,.96); }
.reader-toolbar > div:nth-child(2) { text-align: center; }
.reader-toolbar strong, .reader-toolbar span { display: block; }
.reader-toolbar span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.reader-tools { display: flex; direction: ltr; justify-content: flex-end; gap: 7px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--white); font-size: 21px; }
.icon-button:hover { border-color: var(--forest); }
.reader-stage { width: min(1120px, calc(100% - 48px)); margin: 42px auto; display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 24px; align-items: start; }
.book-page { min-height: calc(100vh - 156px); padding: clamp(38px, 7vw, 90px) clamp(28px, 10vw, 120px) 44px; background: var(--white); box-shadow: 0 20px 50px rgba(30,38,34,.1), inset -12px 0 18px rgba(109,92,62,.045); border-right: 7px solid #ece2d3; }
:root[data-theme="dark"] .book-page { border-right-color: #303936; box-shadow: 0 20px 50px rgba(0,0,0,.28); }
.page-running-head, .page-footer { display: flex; justify-content: space-between; color: #8b8a83; font-size: 10px; }
.book-page h1 { max-width: 640px; margin: 52px auto 32px; color: var(--forest-deep); font-family: Vazirmatn, Tahoma, sans-serif; font-size: 32px; font-weight: 800; text-align: center; line-height: 1.65; }
:root[data-theme="dark"] .book-page h1 { color: var(--saffron); }
.reading-text { max-width: 680px; margin: 0 auto; font-family: Vazirmatn, Tahoma, sans-serif; font-size: 19px; font-weight: 400; line-height: 2.3; }
.reading-text p { margin-bottom: 24px; }
.reading-text.bilingual-reading { max-width: 860px; font-family: Vazirmatn, Tahoma, sans-serif; }
.bilingual-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 34px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.bilingual-pair:first-child { padding-top: 0; }
.bilingual-pair p { margin: 0; }
.source-text { color: #394541; font-family: Georgia, serif; font-size: .92em; line-height: 1.9; text-align: left; }
.translation-text { color: var(--ink); line-height: 2.25; }
.page-footer { max-width: 680px; margin: 48px auto 0; align-items: center; }
.page-ornament { color: var(--coral); font-size: 9px; }
.reflection-sheet { position: sticky; top: 96px; padding: 26px; background: var(--forest); color: #fff; border-radius: var(--radius); }
.reflection-sheet h2 { font-size: 18px; line-height: 1.8; }
.reflection-editor[hidden] { display: none; }
.reflection-editor { margin-top: 12px; }
.reflection-sheet textarea { width: 100%; resize: vertical; padding: 12px; border: 0; border-radius: 4px; background: rgba(255,255,255,.96); line-height: 1.7; }
.reflection-sheet textarea { color: #1f2523; }
.reflection-sheet .primary-button { width: 100%; margin-top: 14px; color: var(--forest); background: var(--saffron); }
.reflection-sheet .quiet-button { width: 100%; color: #d6e1dd; }
.reflection-sheet .reflection-toggle { text-align: right; border-bottom: 1px solid rgba(255,255,255,.22); }
.offline-badge { position: fixed; z-index: 30; left: 14px; bottom: 14px; padding: 7px 11px; border-radius: 4px; color: #fff; background: #7a4635; font-size: 11px; }
dialog { width: min(470px, calc(100% - 28px)); padding: 0; border: 0; border-radius: var(--radius); background: var(--white); box-shadow: 0 24px 80px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(7,28,22,.56); backdrop-filter: blur(3px); }
.settings-card { padding: 28px; }
.settings-card header { display: flex; justify-content: space-between; align-items: start; }
.settings-card h2 { margin-bottom: 24px; }
fieldset { margin: 0 0 22px; padding: 0; border: 0; }
legend { margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.segment-control { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.segment-control button { height: 42px; border: 0; border-left: 1px solid var(--line); background: transparent; }
.segment-control button:last-child { border-left: 0; }
.segment-control button.active { color: #fff; background: var(--forest); }
input[type="time"] { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 5px; background: white; }
:root[data-theme="dark"] input[type="time"] { color: var(--ink); background: var(--paper-deep); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 24px 0; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.toggle-row input { position: absolute; opacity: 0; }
.toggle-row i { width: 44px; height: 24px; flex: 0 0 44px; padding: 3px; border-radius: 20px; background: #c8ccc9; }
.toggle-row i::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle-row input:checked + i { background: var(--forest); }
.toggle-row input:checked + i::after { transform: translateX(-20px); }
.full-button { width: 100%; }
.toast { position: fixed; z-index: 50; bottom: 24px; left: 50%; max-width: calc(100% - 30px); padding: 11px 18px; border-radius: 5px; color: #fff; background: var(--ink); opacity: 0; pointer-events: none; transform: translate(-50%, 20px); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.mobile-nav { display: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 88px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .nav-item:not(.settings-button) { font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item span { font-size: 20px; }
  .sidebar-note { display: none; }
  .settings-button { margin-top: auto; font-size: 0; }
  .home-grid { grid-template-columns: 1fr; }
  .daily-panel { min-height: 220px; }
  .book-row { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-shell { display: block; padding-bottom: 66px; }
  .sidebar { display: none; }
  .topbar { height: 68px; padding: 0 18px; }
  .mobile-brand { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; }
  .mobile-brand .brand-mark { width: 32px; height: 32px; flex-basis: 32px; font-size: 17px; }
  .today-label { display: none; }
  .view { padding: 24px 18px 40px; }
  .continue-band { min-height: 0; grid-template-columns: 112px minmax(0, 1fr); }
  .cover-wrap { min-height: 248px; }
  .cover-type { padding: 16px 12px; }
  .cover-type strong { font-size: 21px; }
  .continue-copy { padding: 20px 18px; }
  .continue-copy h1 { font-size: 24px; }
  .continue-copy p { display: none; }
  .book-meta { display: grid; gap: 3px; margin: 10px 0; }
  .continue-actions { margin-top: 16px; }
  .primary-button { min-height: 42px; padding-inline: 14px; }
  .continue-actions .quiet-button { font-size: 11px; }
  .section-block { margin-top: 38px; }
  .section-heading h2 { font-size: 21px; }
  .library-grid { grid-template-columns: 1fr; }
  .library-grid .book-card { grid-template-columns: 96px 1fr; padding: 14px; }
  .library-grid .mini-cover { height: 142px; }
  .page-heading h1 { font-size: 34px; }
  .stat-band div { padding: 24px 8px; }
  .stat-band span { font-size: 28px; }
  .calendar-grid { grid-template-columns: repeat(7, 1fr); }
  .reader-toolbar { grid-template-columns: 52px minmax(0, 1fr) 132px; padding: 0 10px; }
  .reader-tools .bookmark-button { display: none; }
  .reader-stage { width: 100%; margin: 0; display: block; }
  .book-page { min-height: calc(100vh - 76px); padding: 34px 24px 40px; border-right-width: 4px; box-shadow: none; }
  .book-page h1 { margin: 38px auto 28px; font-size: 26px; }
  .reading-text { font-size: 18px; line-height: 2.2; }
  .bilingual-pair { grid-template-columns: 1fr; gap: 14px; padding: 22px 0; }
  .source-text { padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
  .reflection-sheet { position: static; border-radius: 0; padding: 28px 22px 40px; }
  .mobile-nav { position: fixed; z-index: 10; inset: auto 0 0; height: 66px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: rgba(255,253,248,.96); backdrop-filter: blur(10px); }
  :root[data-theme="dark"] .mobile-nav { background: rgba(29,36,33,.96); }
  .mobile-nav button { display: grid; place-items: center; align-content: center; gap: 2px; border: 0; color: var(--muted); background: transparent; font-size: 10px; }
  .mobile-nav button span { font-size: 19px; }
  .mobile-nav button.active { color: var(--coral); }
}

@media (max-width: 420px) {
  .continue-band { grid-template-columns: 96px minmax(0, 1fr); }
  .cover-type small { display: none; }
  .continue-copy { padding: 16px 14px; }
  .continue-copy h1 { font-size: 21px; }
  .primary-button span { margin-right: 8px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
