:root {
  color-scheme: light;
  --moss: #3E5A4A;
  --sage: #8BAA8F;
  --celadon: #C7D6C9;
  --mist: #E8EFE8;
  --ivory: #F6F7F4;
  --ink: #31463A;
  --muted: #78897C;
  --line: #D7E2D8;
  --paper: var(--ivory);
  --card: rgba(251, 252, 248, .94);
  --solid-card: #FBFCF8;
  --accent: var(--moss);
  --accent-raised: #31493B;
  --accent-soft: var(--mist);
  --danger: #8a3632;
  --warning: #765e21;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(62, 90, 74, .08);
  --shadow-sm: 0 2px 10px rgba(62, 90, 74, .06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at 84% 4%, rgba(199, 214, 201, .62), transparent 27rem),
    radial-gradient(circle at 5% 28%, rgba(232, 239, 232, .92), transparent 34rem),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background-image: linear-gradient(rgba(62, 90, 74, .045) 1px, transparent 1px);
  background-size: 100% 34px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(139, 170, 143, .48);
  outline-offset: 3px;
}

.app-frame {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: max(26px, env(safe-area-inset-top)) 0 max(56px, env(safe-area-inset-bottom));
}

.site-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand-lockup > span:last-child { display: grid; gap: 3px; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: var(--ivory);
  font-family: "Segoe UI Historic", "Noto Sans Runic", serif;
  font-size: 1.72rem;
  line-height: 1;
  box-shadow: var(--shadow-sm);
}

.brand {
  font-size: 1.22rem;
  font-weight: 760;
  letter-spacing: .23em;
  line-height: 1;
}

.brand-subtitle, .brand-version {
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .08em;
}

.brand-version { font-size: .61rem; }

.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(42px, auto));
  align-items: center;
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: var(--mist);
  box-shadow: inset 0 0 0 1px rgba(62, 90, 74, .04);
}

.language-option {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 6px 11px;
  background: transparent;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 760;
  white-space: nowrap;
}

.language-option.is-active {
  background: var(--solid-card);
  color: var(--moss);
  box-shadow: var(--shadow-sm);
}

.version {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(251, 252, 248, .72);
}

.i18n-primary,
.i18n-secondary { display: block; }

.i18n-secondary {
  margin-top: 2px;
  font-size: .72em;
  font-weight: 560;
  letter-spacing: .025em;
  line-height: 1.2;
  opacity: .68;
  text-transform: none;
}

.shell { width: 100%; }

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.calculator-column { min-width: 0; }

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(232, 239, 232, .84);
  backdrop-filter: blur(10px);
  margin-bottom: 14px;
}

.mode-tab {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.mode-tab.is-active {
  background: var(--accent);
  color: var(--ivory);
  box-shadow: 0 6px 18px rgba(62, 90, 74, .14);
}

.panel, .result-stage, .history-section {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel { padding: 28px; }

.panel-heading { margin-bottom: 23px; }
.panel-heading h1 { margin: 4px 0 0; font-size: clamp(1.55rem, 3vw, 2rem); letter-spacing: -.025em; }

.eyebrow {
  margin: 0;
  color: var(--moss);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field { display: grid; gap: 7px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

label {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}

label span { font-weight: 500; opacity: .72; }
label > span[data-i18n] { font-weight: inherit; opacity: 1; }
label > span[data-i18n="optional"] { font-weight: 500; opacity: .72; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 13px;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

input, select { min-height: 46px; }
input::placeholder, textarea::placeholder { color: #9ba39e; }

input:focus, select:focus, textarea:focus {
  border-color: var(--sage);
  background: var(--solid-card);
  box-shadow: 0 0 0 4px rgba(139, 170, 143, .14);
}

.primary, .secondary, .text-button {
  min-height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 10px 17px;
  font-weight: 720;
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease;
}

.primary { background: var(--accent); color: var(--ivory); }
.primary:hover { background: var(--accent-raised); transform: translateY(-1px); }
.secondary { background: var(--accent-soft); color: var(--accent); }
.secondary:hover { background: var(--celadon); }
.text-button { background: rgba(251,252,248,.74); border-color: var(--line); color: var(--muted); }
.text-button:hover { border-color: var(--sage); color: var(--ink); }
.danger-button:hover { border-color: rgba(138, 54, 50, .28); color: var(--danger); }
.form-submit { grid-column: 1 / -1; margin-top: 7px; }

.message {
  min-height: 22px;
  margin: 11px 5px 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.message[data-type="error"] { color: var(--danger); }
.message[data-type="warn"] { color: var(--warning); }
.message[data-type="ok"] { color: var(--accent-raised); }

.result-stage {
  min-height: 574px;
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 36%, rgba(199, 214, 201, .58), transparent 15rem),
    linear-gradient(145deg, rgba(251,252,248,.98), rgba(232,239,232,.84));
}

.result-stage::before {
  content: "";
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(62, 90, 74, .08);
  border-radius: 21px;
  pointer-events: none;
}

.result-empty {
  display: grid;
  place-items: center;
  gap: 20px;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}

.result-empty p { margin: 0; font-size: .84rem; letter-spacing: .04em; }

.calendar-wheel {
  width: 168px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(62, 90, 74, .18);
  border-radius: 50%;
  background: repeating-conic-gradient(from -7.5deg, rgba(62,90,74,.2) 0deg 1deg, transparent 1deg 15deg);
  mask-image: radial-gradient(circle, transparent 0 52%, black 53% 55%, transparent 56% 75%, black 76% 78%, transparent 79%);
  opacity: .65;
}

.calendar-wheel span { font-size: 1px; color: transparent; }

.result-card {
  width: min(100%, 620px);
  padding: 44px 46px 38px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.result-kind {
  margin: 0 0 13px;
  color: var(--moss);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.glyph-field {
  width: min(290px, 72vw);
  aspect-ratio: 1;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(62, 90, 74, .12);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(251,252,248,.98) 0 53%, transparent 54%),
    repeating-conic-gradient(from -7.5deg, rgba(62,90,74,.14) 0deg .8deg, transparent .8deg 15deg);
  box-shadow: inset 0 0 0 15px rgba(251,252,248,.42), 0 18px 44px rgba(62,90,74,.08);
}

.result-glyph {
  font-family: "Segoe UI Historic", "Noto Sans Runic", "Noto Sans Symbols 2", serif;
  font-size: clamp(9rem, 23vw, 13.5rem);
  line-height: .9;
  color: var(--accent);
  filter: drop-shadow(0 9px 12px rgba(62, 90, 74, .12));
}

.result-name {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 720;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.result-range { margin: 7px 0 0; font-size: 1rem; color: var(--muted); }

.result-summary {
  display: grid;
  grid-template-columns: 1.05fr .8fr 1.3fr;
  gap: 0;
  margin: 28px 0 0;
  border-block: 1px solid var(--line);
}

.result-summary div {
  min-width: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
}

.result-summary div:last-child { border-right: 0; }
.result-summary dt { color: var(--muted); font-size: .65rem; letter-spacing: .09em; text-transform: uppercase; }
.result-summary dd { margin: 5px 0 0; font-size: .78rem; font-weight: 720; overflow-wrap: anywhere; }

.result-system { margin: 15px auto 0; color: var(--muted); font-size: .68rem; line-height: 1.5; }
.result-actions { display: flex; justify-content: center; margin-top: 19px; }

.history-section { margin-top: 20px; padding: 25px; }

.sync-card {
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(232, 239, 232, .48);
}

.sync-summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 15px;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 760;
  list-style-position: inside;
  cursor: pointer;
}

.sync-summary-state {
  margin-left: auto;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
}

.sync-panel {
  display: grid;
  gap: 13px;
  padding: 0 15px 15px;
  border-top: 1px solid rgba(62, 90, 74, .08);
}

.sync-hint {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.55;
}

.sync-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .75rem;
}

.sync-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(120, 137, 124, .12);
}

.sync-card.is-connected .sync-status-dot {
  background: var(--sage);
  box-shadow: 0 0 0 4px rgba(139, 170, 143, .16);
}

.sync-button { width: 100%; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head h2 { margin: 4px 0 0; font-size: 1.2rem; letter-spacing: -.01em; }

.history-count {
  display: inline-grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .72rem;
  vertical-align: 2px;
}

.history-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.history-actions button { min-height: 38px; padding: 7px 12px; font-size: .75rem; }
.history-empty { color: var(--muted); text-align: center; padding: 34px 8px; margin: 0; font-size: .84rem; }
.history-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }

.history-item {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.74);
  transition: border-color .15s ease, transform .15s ease, background-color .15s ease;
}

.history-item:hover { border-color: var(--sage); background: var(--solid-card); transform: translateY(-1px); }

.history-main-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
}

.history-open {
  width: 100%;
  min-height: 78px;
  display: flex;
  gap: 13px;
  align-items: center;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 12px 45px 12px 13px;
  color: inherit;
}

.history-glyph {
  flex: 0 0 42px;
  font-family: "Segoe UI Historic", "Noto Sans Runic", serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
  text-align: center;
}

.history-copy { display: grid; gap: 2px; min-width: 0; }
.history-copy strong { font-size: .9rem; }
.history-copy span { color: var(--muted); font-size: .73rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-copy .history-warning { color: var(--warning); white-space: normal; }
.history-copy .history-note { color: var(--ink); white-space: normal; line-height: 1.42; }

.record-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.record-action {
  min-height: 34px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 7px;
  background: rgba(251, 252, 248, .76);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
}

.record-action:hover { border-color: var(--sage); color: var(--ink); }
.record-action.danger-button:hover { color: var(--danger); }

.record-editor { background: var(--solid-card); }

.record-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.record-edit-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.record-edit-field:last-child { grid-column: 1 / -1; }
.record-edit-field input, .record-edit-field textarea { min-height: 42px; padding: 9px 10px; }
.record-edit-field textarea { min-height: 86px; font-family: inherit; }
.record-edit-error { min-height: 18px; color: var(--danger); font-size: .74rem; }

.history-delete {
  position: absolute;
  right: 9px;
  top: 50%;
  translate: 0 -50%;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
}

.history-delete:hover { background: var(--mist); color: var(--danger); }

.dialog {
  width: min(650px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  border: 0;
  border-radius: 24px;
  padding: 0;
  background: var(--solid-card);
  color: var(--ink);
  box-shadow: 0 32px 90px rgba(0,0,0,.28);
}

.dialog::backdrop { background: rgba(15,18,16,.54); backdrop-filter: blur(4px); }
.dialog-inner { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 10px; }
.dialog-head h2 { margin: 3px 0 0; font-size: 1.3rem; }
.dialog-help { margin: 0 0 13px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent; font-size: 1.55rem; color: var(--muted); }
.icon-button:hover { background: var(--mist); }

textarea {
  min-height: 280px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  line-height: 1.5;
}

.dialog-error { min-height: 20px; margin: 8px 2px; color: var(--danger); font-size: .78rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.footer-note {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 18px 5px 0;
  color: var(--muted);
  font-size: .68rem;
  line-height: 1.5;
}

@media (max-width: 880px) {
  .app-frame { width: min(760px, calc(100% - 32px)); }
  .workspace { grid-template-columns: 1fr; }
  .result-stage { min-height: 520px; }
}

@media (max-width: 600px) {
  .app-frame { width: calc(100% - 20px); padding-top: max(18px, env(safe-area-inset-top)); }
  .site-header { min-height: 52px; margin: 0 5px 20px; flex-wrap: wrap; gap: 13px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 1.6rem; }
  .brand { font-size: 1rem; }
  .brand-subtitle, .brand-version { font-size: .58rem; }
  .header-tools { width: 100%; justify-content: flex-end; gap: 8px; }
  .language-switcher { flex: 1 1 auto; grid-template-columns: repeat(3, 1fr); }
  .language-option { padding-inline: 8px; }
  .panel { padding: 22px 18px; border-radius: var(--radius-lg); }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide, .form-submit { grid-column: 1; }
  .result-stage { min-height: 480px; border-radius: var(--radius-lg); }
  .result-stage::before { inset: 12px; border-radius: 17px; }
  .result-card { padding: 34px 20px 27px; }
  .glyph-field { width: min(250px, 70vw); }
  .result-glyph { font-size: clamp(8.5rem, 48vw, 12rem); }
  .result-name { font-size: clamp(1.9rem, 10vw, 2.6rem); }
  .result-summary { grid-template-columns: 1fr 1fr; }
  .result-summary div { border-right: 1px solid var(--line); }
  .result-summary div:nth-child(2) { border-right: 0; }
  .result-summary div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .history-section { padding: 21px 16px; border-radius: var(--radius-lg); }
  .section-head { align-items: stretch; flex-direction: column; }
  .history-actions { display: grid; grid-template-columns: repeat(2, 1fr); width: 100%; }
  .history-actions button { width: 100%; min-height: 44px; }
  .history-delete { width: 42px; height: 42px; right: 5px; }
  .history-list { grid-template-columns: 1fr; }
  .record-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-action { min-height: 40px; }
  .record-edit-grid { grid-template-columns: 1fr; }
  .record-edit-field:last-child { grid-column: 1; }
  .sync-summary { align-items: flex-start; }
  .footer-note { flex-direction: column; gap: 3px; text-align: center; }
  .dialog { width: calc(100% - 18px); border-radius: 21px; }
  .dialog-inner { padding: 20px 16px; }
  textarea { min-height: min(300px, 42dvh); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
