:root {
  color-scheme: light;
  --ink: #24312f;
  --muted: #6c7a76;
  --paper: #eef6f1;
  --mist: #f8fbf8;
  --panel: #ffffff;
  --line: #d6e3dc;
  --sage: #6f9d8f;
  --sage-dark: #426f61;
  --blue: #6d8fa3;
  --gold: #c8a96a;
  --danger: #aa6a5f;
  --shadow: 0 18px 55px rgba(39, 72, 63, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(111, 157, 143, 0.16), transparent 34%),
    linear-gradient(215deg, rgba(109, 143, 163, 0.14), transparent 42%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(16px, 4vw, 34px) 14px;
}

h1 {
  margin-top: 2px;
  font-size: clamp(2.3rem, 9vw, 4.9rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.brand-title {
  display: inline-flex;
  align-items: flex-end;
  gap: clamp(8px, 2vw, 14px);
}

.brand-mark {
  width: clamp(58px, 6vw, 78px);
  height: clamp(58px, 6vw, 78px);
  flex: 0 0 auto;
  margin-bottom: 2px;
  overflow: visible;
}

.mark-label {
  filter: drop-shadow(0 10px 18px rgba(50, 86, 73, 0.12));
}

.mark-route {
  animation: traceFlow 2.8s ease-in-out infinite;
}

.mark-pulse {
  transform-origin: 38px 24px;
  animation: tracePulse 2.8s ease-out infinite;
}

@keyframes traceFlow {
  0% {
    stroke-dashoffset: 28;
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0.55;
  }
}

@keyframes tracePulse {
  0%,
  45% {
    opacity: 0;
    transform: scale(0.7);
  }
  58% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

h2 {
  font-size: clamp(1.55rem, 5vw, 2.5rem);
  line-height: 1;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--sage-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.subhead,
.screen-head p,
.hint {
  color: var(--muted);
  line-height: 1.5;
}

.language-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  min-height: 46px;
  padding: 14px 22px;
  border-radius: 999px;
  border: 1.5px solid #3f7763;
  background: rgba(247, 251, 248, 0.9);
  color: #2f6f5a;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(31, 65, 52, 0.08);
  flex: 0 0 auto;
}

.language-button:hover {
  background: #ffffff;
}

.language-button:focus-visible {
  outline: 3px solid rgba(63, 119, 99, 0.3);
  outline-offset: 4px;
}

.tabbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px clamp(12px, 4vw, 34px);
  background: rgba(238, 246, 241, 0.86);
  backdrop-filter: blur(16px);
}

.tab {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-weight: 850;
}

.tab.is-active {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: #fff;
}

.screen-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 14px clamp(12px, 4vw, 34px) 34px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.screen-head {
  display: grid;
  gap: 10px;
  margin: 10px 0 16px;
}

.split {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.panel,
.facts,
.timeline-item {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--mist);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 11px 13px;
  line-height: 1.25;
}

textarea {
  resize: vertical;
}

input,
select,
textarea,
button {
  touch-action: manipulation;
}

.wide {
  grid-column: 1 / -1;
}

button {
  min-height: 46px;
  border: 1px solid var(--sage-dark);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 900;
}

.primary {
  background: var(--sage-dark);
  color: white;
}

.secondary {
  background: #fff;
  color: var(--sage-dark);
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.full {
  width: 100%;
}

.compact {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 0.78rem;
}

.button-stack {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.timeline-controls[hidden] {
  display: none;
}

.timeline-controls.bottom {
  margin: 14px 0 0;
}

.timeline-controls div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timeline-item {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.tag {
  display: grid;
  place-items: center;
  min-height: 86px;
  border-radius: 14px;
  background: #edf7f2;
  color: var(--sage-dark);
  font-weight: 950;
  text-align: center;
}

.tag svg {
  width: 58px;
  height: 58px;
}

.tag span {
  margin-top: 4px;
  font-size: 0.64rem;
  overflow-wrap: anywhere;
}

.qr-download,
.timeline-item small a {
  color: var(--sage-dark);
  font-weight: 900;
}

.qr-download {
  margin-top: 8px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-size: 0.68rem;
  line-height: 1.2;
  text-decoration: underline;
}

.timeline-item h3 {
  font-size: 1rem;
}

.timeline-item p {
  margin-top: 6px;
  color: var(--muted);
}

.timeline-item .event-time {
  margin-top: 5px;
  color: var(--sage-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.timeline-item small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  gap: 1px;
  margin: 14px 0;
  overflow: hidden;
}

.facts div {
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.66);
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: none;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--ink);
  padding: 14px 16px;
  line-height: 1.45;
}

.toast.is-visible {
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media print {
  body {
    background: #fff;
  }

  .app-header,
  .tabbar,
  .screen-head,
  #screen-create,
  #screen-update,
  .toast,
  .visually-hidden {
    display: none !important;
  }

  .screen-shell {
    width: 100%;
    padding: 0;
  }

  #screen-timeline {
    display: block !important;
  }

  .timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10mm;
  }

  .timeline-item {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #111;
    border-radius: 0;
    padding: 8mm;
  }

  .tag {
    background: #fff;
    border: 1px solid #111;
  }

  .tag svg {
    width: 34mm;
    height: 34mm;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: start;
  }

  .brand-title {
    align-items: center;
    gap: 8px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .tabbar {
    gap: 6px;
  }

  .tab {
    padding: 8px 6px;
    font-size: 0.78rem;
  }

  @media (max-width: 640px) {
    .language-button {
      width: 190px;
      min-height: 46px;
      font-size: 0.92rem;
      padding: 12px 18px;
    }
  }

  .form-grid,
  .settings-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .button-stack {
    justify-content: stretch;
  }

  .button-stack button {
    width: 100%;
  }

  .timeline-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .timeline-controls div,
  .timeline-controls button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mark-route,
  .mark-pulse {
    animation: none;
  }
}
