:root {
  --paper: #E9EDF0; --card: #F7F9FA; --ink: #101820; --muted: #6B7A87;
  --rail: #CBD5DC; --teal: #0F5F66; --teal-ink: #fff; --amber: #C97A00; --red: #A33B2A;
  --shadow: 0 0 0 4px;
  color-scheme: light;
}
[data-theme="dark"] {
  --paper: #0C1316; --card: #151F24; --ink: #E6ECEF; --muted: #8A99A6;
  --rail: #263640; --teal: #3FA6AD; --teal-ink: #06110F; --amber: #E0A24A; --red: #E07A66;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* display qo'yilgan klasslar hidden'ni bosib ketmasin */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--paper);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.5;
  padding: max(28px, env(safe-area-inset-top)) 20px calc(60px + env(safe-area-inset-bottom));
  transition: background .2s ease, color .2s ease;
}
.wrap { max-width: 780px; margin: 0 auto; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: 'Newsreader', Georgia, serif; font-weight: 400; font-size: clamp(34px, 6vw, 52px); line-height: 1.02; margin: 6px 0 4px; letter-spacing: -.01em; }
h1 em { font-style: italic; color: var(--teal); }
.sub { color: var(--muted); max-width: 48ch; margin: 0 0 26px; }
h2 { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; border-top: 1px solid var(--rail); padding-top: 10px; margin: 38px 0 14px; display: flex; justify-content: space-between; align-items: baseline; }
h3 { font-family: 'Newsreader', serif; font-weight: 600; font-size: 22px; margin: 0; }

.icon-btn { background: var(--card); border: 1px solid var(--rail); color: var(--ink); width: 40px; height: 40px; border-radius: 2px; cursor: pointer; font-size: 18px; line-height: 1; flex: none; }
.icon-btn:hover { border-color: var(--teal); color: var(--teal); }
.link { background: none; border: 0; color: var(--teal); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

/* Statistika */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 1px; background: var(--rail); border: 1px solid var(--rail); }
.stat { background: var(--card); padding: 12px 14px; }
.stat b { display: block; font-family: 'Newsreader', serif; font-size: 30px; line-height: 1; }
.stat b.hot { color: var(--amber); }
.stat b.warn { color: var(--red); }
.stat b.good { color: var(--teal); }
.stat span { font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Bugun */
.today-card { background: var(--card); border: 1px solid var(--rail); border-left: 3px solid var(--amber); padding: 15px 16px; margin-bottom: 8px; }
.today-card.late { border-left-color: var(--red); }
.today-words { font-family: 'Newsreader', serif; font-size: 21px; line-height: 1.3; }
.tag { font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.tag.late { color: var(--red); }
.reveal { margin-top: 12px; border-top: 1px dashed var(--rail); padding-top: 10px; }
.reveal .rw { display: flex; gap: 10px; padding: 3px 0; flex-wrap: wrap; align-items: baseline; }
.reveal .rw span:first-child { font-weight: 600; min-width: 90px; }
.reveal .rw span:nth-child(2) { color: var(--teal); }
.reveal .rw em { color: var(--muted); font-size: 13px; font-style: normal; }
.story { margin-top: 8px; font-family: 'Newsreader', serif; font-style: italic; color: var(--muted); font-size: 15px; }
.acts { display: flex; gap: 8px; margin-top: 13px; flex-wrap: wrap; }
.empty { border: 1px dashed var(--rail); padding: 22px; text-align: center; color: var(--muted); }

button.do { background: var(--teal); color: var(--teal-ink); border: 0; padding: 9px 16px; font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; border-radius: 2px; }
button.do:hover { filter: brightness(1.1); }
button.nope { background: none; color: var(--red); border: 1px solid var(--red); padding: 8px 15px; font-family: inherit; font-size: 13px; cursor: pointer; border-radius: 2px; }
button.nope:hover { background: var(--red); color: var(--paper); }
button.show { background: none; color: var(--ink); border: 1px solid var(--rail); padding: 8px 15px; font-family: inherit; font-size: 13px; cursor: pointer; border-radius: 2px; }
button.show:hover { border-color: var(--teal); color: var(--teal); }

/* Sahifalash */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0 2px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .06em; color: var(--muted); }
.pager .pg { width: 32px; height: 32px; padding: 0; border: 1px solid var(--rail); background: var(--card); color: var(--ink); border-radius: 2px; font-size: 16px; line-height: 1; cursor: pointer; }
.pager .pg:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.pager .pg:disabled { opacity: .35; cursor: default; }

/* Form */
.form { background: var(--card); border: 1px solid var(--rail); padding: 16px; }
label { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
input, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--rail); background: var(--paper); font-family: inherit; font-size: 15px; color: var(--ink); border-radius: 2px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .dot:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row .grow { flex: 1 1 260px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.btn-solid { background: var(--ink); color: var(--paper); border: 0; padding: 10px 18px; font-size: 14px; cursor: pointer; border-radius: 2px; height: 38px; font-family: inherit; }
.btn-solid:hover { filter: brightness(1.15); }
.btn-solid.on { background: var(--teal); color: var(--teal-ink); }

/* Zanjir */
.chain { background: var(--card); border: 1px solid var(--rail); padding: 16px 18px 10px; margin-bottom: 12px; }
.chain.full { border-left: 3px solid var(--teal); }
.chain-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.chain-words { font-family: 'Newsreader', serif; font-size: 21px; line-height: 1.25; }
.chain-meta { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); white-space: nowrap; }
.chain-meta .rs { color: var(--red); }
.chain-meta .ok { color: var(--teal); }
.del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 4px; line-height: 1; }
.del:hover { color: var(--red); }

.rail { position: relative; margin: 26px 4px 6px; height: 62px; }
.rail-line { position: absolute; top: 9px; left: 0; right: 0; height: 1px; background: var(--rail); }
.rail-fill { position: absolute; top: 9px; left: 0; height: 1px; background: var(--teal); }
.dot { position: absolute; top: 0; transform: translateX(-50%); background: none; border: 0; padding: 0; cursor: pointer; text-align: center; font-family: 'IBM Plex Mono', monospace; color: var(--muted); }
.dot i { display: block; width: 19px; height: 19px; border-radius: 50%; margin: 0 auto; border: 1.5px solid var(--rail); background: var(--card); transition: transform .15s ease, background .15s ease; }
.dot:hover:not(:disabled) i { transform: scale(1.18); }
/* navbati kelmagan bosqich — bosilmaydi */
.dot:disabled { cursor: default; }
.dot:disabled i { border-style: dashed; }
.dot:disabled b, .dot:disabled s { opacity: .65; }
.dot.done i { background: var(--teal); border-color: var(--teal); }
.dot.due i { border-color: var(--amber); border-width: 2px; box-shadow: var(--shadow) rgba(201,122,0,.16); }
.dot.late i { border-color: var(--red); border-width: 2px; box-shadow: var(--shadow) rgba(163,59,42,.14); }
.dot b { display: block; font-size: 10px; font-weight: 500; margin-top: 6px; letter-spacing: .04em; }
.dot s { display: block; font-size: 9px; text-decoration: none; opacity: .6; margin-top: 1px; }
.dot.done b, .dot.done s { color: var(--teal); }
.dot.due b { color: var(--amber); }
.dot.late b { color: var(--red); }

.toggle { background: none; border: 0; border-top: 1px solid var(--rail); width: 100%; text-align: left; padding: 9px 0 4px; color: var(--muted); cursor: pointer; font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.toggle:hover { color: var(--teal); }
.edit { padding: 6px 0 10px; }
.edit .lbls, .wrow { display: grid; grid-template-columns: 100px 1fr 1.4fr; gap: 8px; }
.wrow { margin-bottom: 6px; align-items: center; }
.wrow > span { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.edit input { font-size: 14px; padding: 7px 8px; }

/* Eslatma */
.notif-main { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; }
.notif-title { font-family: 'Newsreader', serif; font-size: 19px; line-height: 1.2; }
.notif-desc { margin: 5px 0 0; color: var(--muted); font-size: 13px; max-width: 46ch; }

.switch { flex: none; width: 52px; height: 30px; padding: 0; position: relative; cursor: pointer; border: 1px solid var(--rail); background: var(--paper); border-radius: 999px; transition: background .18s ease, border-color .18s ease; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform .18s ease, background .18s ease; }
.switch[aria-checked="true"] { background: var(--teal); border-color: var(--teal); }
.switch[aria-checked="true"] .knob { transform: translateX(22px); background: var(--teal-ink); }
.switch:disabled { opacity: .4; cursor: not-allowed; }

.notif-state { display: flex; align-items: center; gap: 9px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--rail); font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .04em; color: var(--muted); }
.dot-s { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--rail); }
.dot-s.on { background: var(--teal); box-shadow: 0 0 0 3px rgba(63,166,173,.22); }
.dot-s.warn { background: var(--amber); }
.dot-s.err { background: var(--red); }
.notif-state .on ~ span { color: var(--teal); }
.notif-state .warn ~ span { color: var(--amber); }
.notif-state .err ~ span { color: var(--red); }

.notif-more { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--rail); }
#notif-time { max-width: 150px; }
#notif-next:not(:empty) { color: var(--ink); }
.btn-ghost { background: var(--paper); border: 1px solid var(--rail); color: var(--ink); height: 38px; padding: 0 14px; border-radius: 2px; font-family: inherit; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }

/* Zaxira */
.foot { font-size: 12px; color: var(--muted); }
.fbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.foot button { background: var(--card); border: 1px solid var(--rail); color: var(--ink); padding: 7px 12px; cursor: pointer; font-size: 13px; border-radius: 2px; font-family: inherit; }
.foot button:hover { border-color: var(--teal); color: var(--teal); }
.foot button.danger { color: var(--muted); margin-left: auto; }
.foot button.danger:hover { border-color: var(--red); color: var(--red); }
#status { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--teal); }
#status.err { color: var(--red); }
#json-box, #bulk-box { height: 130px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; line-height: 1.45; resize: vertical; }
#bulk-box { height: 150px; }

.credit { margin-top: 34px; font-size: 11px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; letter-spacing: .04em; }
#offline-badge.on { color: var(--teal); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow: auto; z-index: 50; }
.modal-card { background: var(--paper); border: 1px solid var(--rail); border-radius: 3px; padding: 20px; max-width: 620px; width: 100%; margin-top: 6vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
code { font-family: 'IBM Plex Mono', monospace; font-size: .92em; background: var(--card); padding: 1px 5px; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 560px) {
  .edit .lbls { display: none; }
  .wrow { grid-template-columns: 1fr; border-bottom: 1px solid var(--rail); padding-bottom: 8px; }
  .stat b { font-size: 26px; }
}
