/* తెలుగు పంచాంగం — design system
 * Vernacular: gantala-panchangam turmeric paper, kumkum used functionally
 * (today, selection, festivals), and the day drawn as a strip of light that
 * shadow-planet periods literally darken. One bold element: the timeline.
 */
:root {
  --lblw: 118px;
  --paper: #f7edd4;
  --surface: #fdf8ea;
  --surface2: #f1e4c3;
  --ink: #2b2014;
  --muted: #7d6b50;
  --line: #d9c9a3;
  --kumkum: #a31621;
  --kumkum-soft: rgba(163, 22, 33, 0.12);
  --gold: #9a6d0b;
  --gold-band: rgba(224, 172, 49, 0.55);
  --gold-edge: #b98a1c;
  --good: #2e6b34;
  --good-band: rgba(76, 145, 80, 0.45);
  --bad-band: rgba(163, 22, 33, 0.30);
  --umbra: #4a4238;
  --umbra-band: rgba(74, 66, 56, 0.75);
  --night: #303a5e;
  --daylight: linear-gradient(90deg, #35406b 0%, #7c6a8e 9%, #e8a94e 13.5%, #f7e9b8 22%, #fdf6d8 50%, #f7e9b8 78%, #e8a94e 86.5%, #7c6a8e 91%, #35406b 100%);
  --tl-night: #35406b;
  --tl-dawn: #e8a94e;
  --tl-dawn2: #f7e9b8;
  --tl-mid: #fdf6d8;
  --shadow: 0 1px 0 rgba(90, 70, 40, 0.14);
  --focus: 2px solid #8a5a00;
}
[data-theme="dark"] {
  --paper: #17130e;
  --surface: #211b13;
  --surface2: #2b2318;
  --ink: #f0e5cd;
  --muted: #a89473;
  --line: #453a28;
  --kumkum: #e05744;
  --kumkum-soft: rgba(224, 87, 68, 0.16);
  --gold: #e3b34c;
  --gold-band: rgba(227, 179, 76, 0.5);
  --gold-edge: #e3b34c;
  --good: #6cb974;
  --good-band: rgba(99, 176, 107, 0.4);
  --bad-band: rgba(224, 87, 68, 0.3);
  --umbra: #0c0a07;
  --umbra-band: rgba(5, 4, 3, 0.82);
  --night: #131b38;
  --daylight: linear-gradient(90deg, #10162e 0%, #3a3050 9%, #a06a2a 13.5%, #c9a355 22%, #e0c573 50%, #c9a355 78%, #a06a2a 86.5%, #3a3050 91%, #10162e 100%);
  --tl-night: #10162e;
  --tl-dawn: #a06a2a;
  --tl-dawn2: #c9a355;
  --tl-mid: #e0c573;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Noto Sans Telugu', 'Noto Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
h1, h2, h3, .serif { font-family: 'Noto Serif Telugu', 'Noto Serif', Georgia, serif; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: var(--focus); outline-offset: 2px; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px 48px; }

/* ---- header ---- */
.masthead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 18px 0 10px;
  border-bottom: 3px double var(--kumkum);
}
.masthead h1 { font-size: 1.55rem; margin: 0; font-weight: 600; letter-spacing: 0.01em; }
.masthead h1 .dot { color: var(--kumkum); }
.masthead .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.masthead select, .ctrl {
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 10px; box-shadow: var(--shadow);
}
.lang-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.lang-toggle button { border: 0; background: var(--surface); padding: 6px 12px; }
.lang-toggle button[aria-pressed="true"] { background: var(--kumkum); color: #fff8ee; }

/* ---- nav row ---- */
.navrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 0; }
.views { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.views button { border: 0; background: transparent; padding: 7px 16px; }
.views button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.monthmode { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.monthmode button { border: 0; background: transparent; padding: 7px 12px; font-size: 0.92rem; }
.monthmode button[aria-pressed="true"] { background: var(--surface2); font-weight: 600; }
.datenav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.datenav button { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; }
.datepick { position: relative; display: inline-block; }
.datepick #dateBtn { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; font-variant-numeric: tabular-nums; }
.datepick input[type="date"] { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; height: 100%; border: 0; padding: 0; }

/* ---- day hero ---- */
.dayhero { padding: 10px 0 4px; }
.dayhero .gdate { font-size: 1.7rem; font-weight: 600; margin: 0; }
.dayhero .tline { color: var(--muted); margin: 2px 0 0; }
.dayhero .tline strong { color: var(--ink); font-weight: 600; }
.dayhero .samvat { color: var(--kumkum); font-weight: 600; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.badge {
  border-radius: 999px; padding: 3px 13px; font-size: 0.95rem;
  background: var(--kumkum); color: #fff6e8; font-weight: 600;
}
.badge.moonday { background: var(--night); }
.gdate .badge.moonday { font-size: 1rem; vertical-align: middle; margin-left: 6px; }
.badge.eclipse { background: transparent; color: var(--ink); border: 1.5px dashed var(--kumkum); font-weight: 600; }
.badge.masam-new { background: var(--gold-edge); color: #241a04; }

/* ---- timeline ---- */
.timeline { margin: 18px 0 8px; user-select: none; }
.tl-grid { position: relative; }
.tl-row { display: grid; grid-template-columns: var(--lblw) 1fr; align-items: center; min-height: 26px; }
.tl-row .lbl { font-size: 0.88rem; color: var(--muted); padding-right: 10px; text-align: right; line-height: 1.2; }
button.lbl {
  background: none; border: 0; padding: 0 10px 0 0; cursor: pointer;
  text-decoration: underline dotted var(--line) 1.5px; text-underline-offset: 3px;
}
button.lbl:hover { color: var(--ink); text-decoration-color: var(--muted); }
.infopop {
  margin: 2px 0 8px var(--lblw); background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 14px; font-size: 0.9rem; color: var(--muted);
}
.infopop strong { color: var(--ink); }
.tl-overlay { position: absolute; top: 0; bottom: 0; left: var(--lblw); right: 0; z-index: 4; }
.ruler {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 1.5px dashed var(--muted); pointer-events: none; z-index: 6;
}
.ruler .rtime {
  position: absolute; top: -24px; left: 0; transform: translateX(-50%);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  background: var(--ink); color: var(--paper); padding: 1px 7px; border-radius: 4px;
}
.tl-row.axis { min-height: 44px; margin-bottom: 4px; }
.tl-row.axis .lbl { font-weight: 600; color: var(--ink); }
.track { position: relative; height: 18px; }
.axis .track { height: 34px; border-radius: 6px; background: var(--daylight); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }
.tl-row:not(.axis) .track { border-top: 1px dotted var(--line); height: 22px; }
.tl-row:not(.axis):first-child .track { border-top: 0; }
.tick { position: absolute; top: 100%; transform: translateX(-50%); font-size: 0.72rem; color: var(--muted); padding-top: 2px; }
.sunmark {
  position: absolute; top: -18px; transform: translateX(-50%); font-size: 0.72rem;
  color: var(--ink); font-weight: 600; white-space: nowrap;
  background: var(--paper); padding: 0 5px; border-radius: 4px; z-index: 2;
}
.band { position: absolute; top: 3px; height: 16px; border-radius: 5px; }
.band.bad { background: var(--bad-band); box-shadow: inset 0 0 0 1px var(--kumkum); }
.band.red { background: color-mix(in srgb, var(--kumkum) 72%, transparent); box-shadow: inset 0 0 0 1px var(--kumkum); }
.band.good { background: var(--good-band); box-shadow: inset 0 0 0 1px var(--good); }
.band .bt {
  position: absolute; left: 100%; margin-left: 7px; top: 50%; transform: translateY(-50%);
  font-size: 0.72rem; color: var(--muted); white-space: nowrap; pointer-events: none;
}
.band .bt.flip { left: auto; right: 100%; margin-right: 7px; }
.clip {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 0.6rem; line-height: 1; color: var(--ink); opacity: 0.85; pointer-events: none;
}
.clip.l { left: 2px; } .clip.r { right: 2px; }
.trknote {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-size: 0.72rem; color: var(--muted); font-style: italic; white-space: nowrap;
}
.nowline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--kumkum); z-index: 3; }
.nowline::after { content: ''; position: absolute; top: -4px; left: -3px; border: 4px solid transparent; border-top-color: var(--kumkum); }

/* selection */
.tl-selectable { position: relative; touch-action: pan-y; }
.selband {
  position: absolute; top: 0; bottom: 0; z-index: 4;
  background: var(--kumkum-soft);
  border-left: 2px solid var(--kumkum); border-right: 2px solid var(--kumkum);
  cursor: grab;
}
.selband .handle {
  position: absolute; top: 0; bottom: 0; width: 14px; cursor: ew-resize;
}
.selband .handle.l { left: -8px; } .selband .handle.r { right: -8px; }
.selband .seltime {
  position: absolute; top: -24px; left: 50%; transform: translateX(-50%);
  font-size: 0.78rem; color: var(--kumkum);
  font-weight: 700; white-space: nowrap; background: var(--paper); padding: 0 5px; border-radius: 4px;
}

.sel-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 6px; }
.sel-controls .hint { color: var(--muted); font-size: 0.95rem; flex: 1 1 260px; min-width: 0; }
/* inputs + clear + copy stay together; the group wraps as one unit if tight */
.sel-actions { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (min-width: 641px) { .sel-actions { flex-wrap: nowrap; } }
.sel-controls input[type="time"] { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; }
.btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 16px; box-shadow: var(--shadow);
}
.btn.primary { background: var(--kumkum); border-color: var(--kumkum); color: #fff6e8; font-weight: 600; }
.btn:disabled { opacity: 0.45; cursor: default; }

.verdict { border-radius: 10px; padding: 12px 16px; margin: 10px 0; background: var(--surface); border: 1px solid var(--line); }
.verdict.ok { border-color: var(--good); }
.verdict.warn { border-color: var(--kumkum); }
.verdict p { margin: 2px 0; }
.verdict .w { color: var(--kumkum); font-weight: 600; }
.verdict .g { color: var(--good); font-weight: 600; }

/* ---- details ---- */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin: 18px 0; }
.dcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.dcard .k { font-size: 0.85rem; color: var(--muted); }
.dcard .v { font-weight: 600; }
.dcard .v small { font-weight: 400; color: var(--muted); }

.eclipse-card { border: 1.5px dashed var(--kumkum); border-radius: 10px; padding: 10px 16px; margin: 12px 0; background: var(--surface); }

/* ---- explainers ---- */
details.explain { margin: 22px 0; border-top: 1px solid var(--line); padding-top: 10px; }
details.explain summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; }
.explain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.explain-grid .pi { background: var(--surface); border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line); }
.explain-grid .pi h3 { margin: 0 0 4px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.explain-grid .pi p { margin: 0; font-size: 0.92rem; color: var(--muted); }
.swatch { display: inline-block; width: 20px; height: 12px; border-radius: 4px; }
.swatch.bad { background: var(--bad-band); box-shadow: inset 0 0 0 1px var(--kumkum); }
.swatch.red { background: color-mix(in srgb, var(--kumkum) 72%, transparent); box-shadow: inset 0 0 0 1px var(--kumkum); }
.swatch.good { background: var(--good-band); box-shadow: inset 0 0 0 1px var(--good); }

/* ---- month grid ---- */
.mhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; padding: 8px 0 2px; }
.mhead h2 { margin: 0; font-size: 1.45rem; font-weight: 600; }
.mhead .sub { color: var(--muted); }
.mhead .sub .samvat { color: var(--kumkum); font-weight: 600; }
.mgrid { display: grid; grid-template-columns: 22px repeat(7, 1fr) 22px; gap: 4px; margin-top: 10px; }
.wkjump {
  border: 0; background: none; cursor: pointer; border-radius: 7px; padding: 0;
  color: var(--muted); font-size: 0.72rem;
  display: flex; align-items: center; justify-content: center;
}
.wkjump:hover { background: var(--surface2); color: var(--ink); }
.mgrid .dow { text-align: center; font-size: 0.85rem; color: var(--muted); padding: 4px 0; }
.mgrid .dow.sun { color: var(--kumkum); }
.cell {
  position: relative; min-height: 86px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); padding: 6px 7px 4px; text-align: left; display: block; width: 100%;
  transition: border-color 0.12s;
}
.cell:hover { border-color: var(--muted); }
.cell.out { opacity: 0.38; }
.cell.today { border: 2px solid var(--kumkum); }
.cell.amavasya { background: color-mix(in srgb, var(--night) 14%, var(--surface)); }
.cell.pournami { background: color-mix(in srgb, #e8c15a 22%, var(--surface)); }
.cell .dnum { font-weight: 700; font-size: 1.05rem; }
.cell .dnum .moon { font-size: 0.85rem; margin-left: 4px; }
.cell.sun .dnum { color: var(--kumkum); }
.cell .ti { font-size: 0.78rem; color: var(--muted); line-height: 1.25; }
.cell .fest { font-size: 0.78rem; color: var(--kumkum); font-weight: 700; line-height: 1.2; margin-top: 2px; }
.cell .newmasam {
  display: inline-block; font-size: 0.72rem; background: var(--gold-band);
  border-radius: 5px; padding: 0 5px; margin-top: 2px; color: var(--ink); font-weight: 600;
}
.cell .ecl { font-size: 0.75rem; margin-top: 2px; color: var(--ink); border: 1px dashed var(--kumkum); display: inline-block; border-radius: 5px; padding: 0 5px; }
.cell .ekd { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold-edge); }
.moonword { font-size: 0.75rem; font-weight: 700; }
.cell.amavasya .moonword { color: var(--night); }
[data-theme="dark"] .cell.amavasya .moonword { color: #aab4e0; }
.cell.pournami .moonword { color: #8a6a10; }

/* month legend */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 0; font-size: 0.85rem; color: var(--muted); align-items: center; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }

/* ---- week view (days as columns, time flows downward) ---- */
.wv { margin-top: 14px; }
.wv-head, .wv-body { display: grid; grid-template-columns: 52px repeat(7, 1fr); gap: 5px; }
.wv-hd {
  background: none; border: 0; cursor: pointer; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 2px 7px;
  min-width: 0;
}
.wv-hd:hover { background: var(--surface); }
.wv-hd .dn { font-weight: 700; font-size: 1.05rem; }
.wv-hd .wd { color: var(--muted); font-size: 0.8rem; }
.wv-hd.today .dn, .wv-hd.today .wd { color: var(--kumkum); }
.wv-hd .fs {
  font-size: 0.68rem; color: var(--kumkum); font-weight: 600; line-height: 1.2;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wv-body { position: relative; }
.wv-tip {
  position: absolute; z-index: 10; transform: translate(-50%, -135%);
  background: var(--ink); color: var(--paper); font-size: 0.78rem; font-weight: 600;
  padding: 2px 9px; border-radius: 5px; pointer-events: none; white-space: nowrap;
}
.wv-gcol { position: relative; }
.wv-tick { position: absolute; right: 8px; transform: translateY(-50%); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.wv-col {
  position: relative; height: 540px; border: 0; border-radius: 8px; cursor: pointer; padding: 0;
  background: linear-gradient(180deg, var(--tl-night) 0%, var(--tl-dawn) 12%, var(--tl-dawn2) 19%, var(--tl-mid) 30%, var(--tl-mid) 70%, var(--tl-dawn2) 81%, var(--tl-dawn) 88%, var(--tl-night) 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.wv-col.today { outline: 2px solid var(--kumkum); outline-offset: 1px; }
.vband { position: absolute; left: 8%; width: 54%; border-radius: 4px; }
.vband.red { background: color-mix(in srgb, var(--kumkum) 72%, transparent); box-shadow: inset 0 0 0 1px var(--kumkum); }
.vband.bad { background: var(--bad-band); box-shadow: inset 0 0 0 1px var(--kumkum); }
.vband.good { left: 68%; width: 24%; background: var(--good-band); box-shadow: inset 0 0 0 1px var(--good); }
.wv-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--kumkum); }

/* ---- footer ---- */
.foot { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 0.85rem; }
.foot a { color: inherit; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); border-radius: 9px; padding: 9px 20px;
  opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }

@media (max-width: 640px) {
  :root { --lblw: 86px; }
  .wv-head, .wv-body { grid-template-columns: 40px repeat(7, 1fr); gap: 3px; }
  .wv-col { height: 420px; }
  .wv-hd .fs { display: none; }
  .wv-tick { right: 4px; font-size: 0.65rem; }
  .tl-row .lbl { font-size: 0.78rem; }
  .cell { min-height: 68px; padding: 4px 5px 3px; }
  .mgrid { grid-template-columns: 15px repeat(7, 1fr) 15px; }
  .cell .ti { display: none; }
  .cell .fest { font-size: 0.68rem; }
  .mgrid { gap: 3px; }
  .dayhero .gdate { font-size: 1.35rem; }
  .datenav { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
