/* DateCalc — "precision of the calendar": warm paper neutrals + amber/coral accent.
   Large result numbers. Light default; dark via prefers-color-scheme. RTL aware. */

:root {
  /* light (warm paper) */
  --bg: #f7f3ec;
  --bg-2: #efe9de;
  --panel: #fffdf8;
  --panel-2: #f3ede1;
  --line: #e0d6c3;
  --line-strong: #c3b69d;
  --ink: #2a2118;
  --ink-soft: #6b5e4d;
  --ink-faint: #9b8e7b;
  --accent: #d97706;        /* amber-600 */
  --accent-deep: #b45309;
  --accent-2: #e9573e;      /* coral */
  --accent-soft: rgba(217, 119, 6, 0.12);
  --accent-glow: rgba(217, 119, 6, 0.24);
  --coral-soft: rgba(233, 87, 62, 0.12);
  --ok: #2f9e6f;
  --err: #c0392b;
  --radius: 14px;
  --radius-sm: 10px;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  --display: "Inter", "Apple SD Gothic Neo", sans-serif;
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native LIGHT. Opposite (dark) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="dark"]{
  --bg: #1e1b15;
  --bg-2: #090806;
  --panel: #363227;
  --panel-2: #0f0e0b;
  --line: rgba(255,255,255,0.12);
  --line-strong: rgba(255,255,255,0.12);
  --ink: #d1c0ae;
  --ink-soft: #a99b88;
  --ink-faint: #8b7d69;
  --accent: #cb7006;
  --accent-deep: #da650b;
  --accent-2: #e9563d;
  --accent-soft: #cb7006;
  --accent-glow: rgba(0,0,0,0.40);
  --coral-soft: #e9563d;
  --ok: #2d986b;
  --err: #d96256;
}












@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1410;
    --bg-2: #221a14;
    --panel: #2a201a;
    --panel-2: #322820;
    --line: #3d3024;
    --line-strong: #524231;
    --ink: #f3e9da;
    --ink-soft: #c0b29c;
    --ink-faint: #8a7c66;
    --accent: #fbbf24;       /* amber-400 for dark */
    --accent-deep: #fcd34d;
    --accent-2: #ff7a5c;
    --accent-soft: rgba(251, 191, 36, 0.14);
    --accent-glow: rgba(251, 191, 36, 0.34);
    --coral-soft: rgba(255, 122, 92, 0.16);
    --ok: #4ec98f;
    --err: #f47067;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background:
    radial-gradient(900px 520px at 88% -8%, var(--coral-soft), transparent 60%),
    radial-gradient(700px 460px at -4% 108%, var(--accent-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
b, h1, h2, h3 { font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* i18n switcher theming */
.i18n-switch {
  --i18n-switch-bg: var(--panel-2);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: var(--accent-soft);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--panel);
  --i18n-switch-menu-border: var(--line);
}

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  max-width: 860px;
  margin: 0 auto;
  padding: 22px clamp(16px, 5vw, 32px) 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 8px 22px -10px var(--accent-glow);
  letter-spacing: -.04em;
}
.brand h1 {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: -.015em;
  line-height: 1.1;
}
.brand p { font-size: 12.5px; color: var(--ink-soft); }
.brand .accent { color: var(--accent); }

.offline-badge {
  display: none; /* shown on >= 760px */
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: .02em;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.offline-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── search + chips ─────────────────────────────────────── */
.head {
  max-width: 860px;
  margin: 0 auto;
  padding: 6px clamp(16px, 5vw, 32px) 0;
}
.searchbar { position: relative; margin: 8px 0 12px; }
.searchbar input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  padding: 11px 14px 11px 38px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.searchbar input::placeholder { color: var(--ink-faint); }
.searchbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbar .ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 16px; pointer-events: none;
}

.chips {
  display: flex; gap: 7px; overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: thin;
}
.chips::-webkit-scrollbar { height: 6px; }
.chips::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.chip {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
@media (pointer: coarse) { .chip { min-height: 44px; display: inline-flex; align-items: center; } }
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.is-active {
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px -6px var(--accent-glow);
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── card ───────────────────────────────────────────────── */
.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 4px clamp(16px, 5vw, 32px) 40px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.cat-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.hint {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: right;
  max-width: 60%;
}

.panel { padding: 22px 20px 20px; }

/* ── form rows ──────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field:last-child { margin-bottom: 0; }
.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.field-row .field { flex: 1; min-width: 120px; margin-bottom: 0; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .01em;
}
.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[type="date"], .input[type="time"] { font-family: var(--mono); }

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%),
                    linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}

/* segmented control for operation (+/-) */
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg button {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .12s ease;
}
.seg button.is-on {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px -3px var(--accent-glow);
}
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* checkbox row */
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.btn {
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, opacity .15s;
  box-shadow: 0 6px 18px -8px var(--accent-glow);
  letter-spacing: -.01em;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-ghost {
  background: var(--panel-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

/* ── result display ─────────────────────────────────────── */
.result {
  margin-top: 22px;
  padding: 24px 20px;
  background: linear-gradient(180deg, var(--accent-soft), transparent 90%);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  text-align: center;
}
.result-label {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
  font-weight: 600;
}
.result-big {
  font-family: var(--display);
  font-size: clamp(34px, 9vw, 52px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.03em;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  word-break: keep-all;
}
.result-sub {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.result-sub b { color: var(--ink); }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.result-cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
}
.result-cell .num {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.02em;
}
.result-cell .cap {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 3px;
  font-weight: 500;
}
.result-empty {
  padding: 30px 16px;
  color: var(--ink-faint);
  font-size: 13.5px;
  text-align: center;
}
.result-error {
  color: var(--err);
  font-size: 13.5px;
  margin-top: 10px;
  font-weight: 600;
}

/* ── ad slots (money-lab pattern) ───────────────────────── */
.ad-slot { display: none; margin: 24px 0; }
.ad-slot.is-live, .ad-slot.is-preview { display: block; }
.ad-label {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: .8;
  margin-bottom: 5px;
  text-align: center;
}
.ad-ph {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
}
.ad-slot.is-preview .ad-ph { display: flex; }
.ad-slot.is-preview .adsbygoogle { display: none !important; }
.ad-slot.is-live .ad-ph { display: none; }

/* ── info / FAQ ─────────────────────────────────────────── */
.info {
  margin-top: 28px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}
.info h2 { font-size: 15px; color: var(--ink); margin: 22px 0 8px; }
.info > h2:first-child { margin-top: 0; }
.info p { margin-bottom: 8px; }
.info b { color: var(--ink); }
.faq { margin: 4px 0 8px; }
.faq dt { color: var(--ink); font-weight: 600; margin-top: 12px; }
.faq dd { margin: 4px 0 0; }

.disclaimer {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.65;
  text-align: center;
  padding: 0 8px;
}
.disclaimer b { color: var(--ink); }

/* ── footer ─────────────────────────────────────────────── */
.foot {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px clamp(16px, 5vw, 32px) 80px;
  text-align: center;
}
.foot a { color: var(--ink-faint); font-size: 12px; }
.foot a:hover { color: var(--accent); }

/* ── toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: var(--err); color: #fff; }

/* ── RTL ────────────────────────────────────────────────── */
[dir="rtl"] .searchbar input { padding: 11px 38px 11px 14px; }
[dir="rtl"] .searchbar .ico { left: auto; right: 13px; }
[dir="rtl"] .hint { text-align: left; }
[dir="rtl"] select.input {
  background-position: 18px 50%, 13px 50%;
  padding-right: 13px;
  padding-left: 32px;
}

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding-top: 18px; }
  .brand h1 { font-size: 18px; }
  .hint { display: none; }
  .cat-title { font-size: 16px; }
  .offline-badge { display: none !important; }
  .card-head { padding: 14px 16px; }
  .panel { padding: 18px 16px 16px; }
  .result { padding: 20px 14px; }
}

@media (min-width: 760px) {
  .offline-badge { display: inline-flex; }
}

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