@font-face {
  font-family: Geologica;
  src: url("/fonts/geologica.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: Sofia;
  src: url("/fonts/sofia-sans-extra-condensed.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #101013;
  --surface: #19191e;
  --surface-raised: #242429;
  --text: #f5f4ef;
  --muted: #b0afb9;
  --border: #323239;
  --accent: #ffd54e;
  --accent-bg: #ffd54e1c;
  --nav-bottom: calc(14px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--text);
  font: 500 14px/1.55 Geologica, Arial, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }

:where(button, a, summary, input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
}

h1, p { margin-top: 0; }

h1 {
  margin-bottom: 18px;
  font: 800 clamp(46px, 8vw, 66px)/.98 Sofia, "Arial Narrow", Geologica, sans-serif;
}

.shell {
  width: min(100% - 32px, 648px);
  margin-inline: auto;
  padding-top: max(28px, env(safe-area-inset-top));
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.shell:has(.add-entry) { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }

.object-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 78px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
  color: var(--text);
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 750;
  text-decoration: none;
}

.object-card:hover { background: var(--surface-raised); }

.object-pin, .object-arrow {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-bg);
  color: var(--accent);
}

.object-arrow { background: transparent; }

.date-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 5px;
  align-items: center;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-raised);
}

.icon-button:hover:not(:disabled) { background: #303038; }
.icon-button svg { width: 18px; height: 18px; }
.date-panel .icon-button { color: var(--accent); }

.date-select {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 42px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 750;
}

.date-select:focus-within { outline: 2px solid var(--accent); }

.date-select input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.date-select input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  cursor: pointer;
}

.timeline {
  --time-width: 45px;
  --marker-width: 36px;
  --column-gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.time-row, .boundary, .empty {
  position: relative;
  display: grid;
  grid-template-columns: var(--time-width) var(--marker-width) minmax(0, 1fr);
  column-gap: var(--column-gap);
  align-items: start;
}

.timeline > li:not(:last-child)::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--time-width) + var(--column-gap) + (var(--marker-width) - 2px) / 2);
  width: 2px;
  background: #3c3a34;
  content: "";
}

.timeline > li:first-child::before { top: calc(var(--marker-width) / 2); }

.time-row {
  padding-bottom: 9px;
  scroll-margin-bottom: calc(138px + env(safe-area-inset-bottom));
}

.timeline time {
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: var(--marker-width);
  text-align: right;
}

.event-icon, .boundary-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--marker-width);
  height: var(--marker-width);
}

.event-icon {
  border: 1px solid #5c4d2b;
  border-radius: 11px;
  background: #272217;
  color: var(--accent);
}

.event-icon.kind-supply {
  border-color: #8b7132;
  background: #3d3116;
}

.event-icon.kind-break, .event-icon.kind-note {
  border-color: #453e2d;
  background: #242118;
}

.event-icon svg { width: 18px; height: 18px; }

.boundary, .empty {
  align-items: center;
  min-height: var(--marker-width);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.timeline > .boundary:last-child::before {
  position: absolute;
  top: 0;
  bottom: calc(var(--marker-width) / 2);
  left: calc(var(--time-width) + var(--column-gap) + (var(--marker-width) - 2px) / 2);
  width: 2px;
  background: #3c3a34;
  content: "";
}

.boundary-icon::before {
  width: 7px;
  height: 7px;
  border: 2px solid #a38948;
  border-radius: 50%;
  background: var(--background);
  content: "";
}

.empty { min-height: 84px; }
.empty span { grid-column: 3; }

.event-card {
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}

.event-tag {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.event-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.35;
}

.details-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  list-style: none;
  cursor: pointer;
}

.details-toggle::-webkit-details-marker { display: none; }
.details-toggle svg { width: 13px; height: 13px; }
details[open] .details-toggle svg { transform: rotate(180deg); }

.event-details {
  margin: 0;
  padding-top: 8px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
}

.event-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  margin-top: 4px;
}

.edit-link, .delete-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #ffaba4;
  font-size: 11px;
  font-weight: 750;
}

.edit-link { color: var(--accent); }
.edit-link:hover { background: var(--accent-bg); }
.delete-link:hover { background: #ff918d12; }
.edit-link svg, .delete-link svg { width: 15px; height: 15px; }

.thumbnails { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }

.thumb {
  width: 88px;
  height: 67px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-raised);
}

.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.add-entry {
  position: fixed;
  z-index: 4;
  right: max(16px, calc((100% - 380px) / 2));
  bottom: calc(var(--nav-bottom) + 65px);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #ffdf78;
  border-radius: 50%;
  background: var(--accent);
  color: #211a08;
  box-shadow: inset 0 1px 1px #ffffff65, 0 5px 16px #0008;
}

.add-entry:hover { background: #ffe078; }
.add-entry svg { width: 25px; height: 25px; }

.glass-nav {
  position: fixed;
  z-index: 3;
  inset-inline: 0;
  bottom: var(--nav-bottom);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: min(100% - 32px, 380px);
  margin-inline: auto;
  padding: 5px;
  border: 1px solid #ffffff2b;
  border-radius: 999px;
  background: linear-gradient(155deg, #ffffff18, transparent 48%, #ffd54e09), #222227d6;
  box-shadow: inset 0 1px 1px #ffffff2c, inset 0 -1px 1px #ffffff12, 0 9px 30px #0008;
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  backdrop-filter: blur(20px) saturate(1.35);
}

.glass-nav button {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: clamp(12px, 3.6vw, 14px);
  font-weight: 750;
}

.glass-nav button:hover { background: #ffffff0e; }

.glass-nav button[aria-pressed="true"] {
  border-color: #ffd54e4a;
  background: linear-gradient(155deg, #ffd54e24, #ffd54e11);
  box-shadow: inset 0 1px 1px #fff2bc26;
  color: var(--accent);
}

.material-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.material-card {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
}

.material-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.material-heading h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 750;
}

.material-heading p, .material-empty { color: var(--muted); }
.material-heading p { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 12px; }
.material-edit { flex: none; width: 38px; height: 38px; color: var(--accent); }

.material-amounts {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.material-amounts dt { color: var(--muted); font-size: 11px; }
.material-amounts dd { margin: 0; overflow-wrap: anywhere; font-weight: 750; }
.material-amounts > :last-child dd { color: var(--accent); }
.material-card .thumb { width: min(88px, calc((100% - 16px) / 3)); }

.access-card {
  max-width: 460px;
  margin: 24px auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
}

.access-card h1 { font-size: clamp(36px, 8vw, 52px); margin-bottom: 9px; }
.access-card p { color: var(--muted); }
.access-card form, .access-card label { display: grid; gap: 9px; }
.access-card label { font-weight: 650; }

.access-card input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  font-size: 16px;
}

.action {
  justify-self: start;
  padding: 9px 15px;
  border: 1px solid #f5c540;
  border-radius: 10px;
  background: var(--accent);
  color: #171206;
  font-weight: 750;
}

.action:hover:not(:disabled) { background: #ffe078; }

.form-error, .access-card .form-error { margin: 8px 0 0; color: #ff9b90; font-size: 12px; }

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

.editor {
  width: min(100% - 24px, 490px);
  max-width: none;
  max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
  color: var(--text);
}

.editor::backdrop { background: #0009; }

.editor-header, .editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px;
}

.editor-header { border-bottom: 1px solid var(--border); }
.editor-footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.editor-header h2 { margin: 0; font: 800 39px/.98 Sofia, Geologica, sans-serif; }

.delete-dialog { width: min(100% - 24px, 390px); }
.delete-dialog #delete-entry-title { margin: 0; overflow-wrap: anywhere; color: var(--muted); }

.cancel-action {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--text);
}

.cancel-action:hover:not(:disabled) { background: #303038; }

.delete-action {
  border-color: #ff9a92;
  background: #ffaaa2;
  color: #2a100e;
}

.delete-action:hover:not(:disabled) { background: #ffc1bb; }

.editor-fields { display: grid; gap: 10px; padding: 12px 15px; }
.editor-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px; }
.editor label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }

.editor input:not([type=file]), .editor select, .editor textarea {
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--background);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
}

.editor textarea { min-height: 68px; resize: vertical; }

.material-quantities, .material-dimensions {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.material-quantities { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.editor .photo-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  padding: 8px;
  border: 1px dashed #746136;
  border-radius: 9px;
  color: var(--accent);
}

.photo-picker:focus-within { outline: 2px solid var(--accent); }
.photo-picker small { margin-left: 4px; color: var(--muted); font-size: 11px; }

.photo-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.editor .thumbnails { margin-top: 0; }
.draft-photo { position: relative; width: 67px; height: 51px; }
.draft-photo img { width: 100%; height: 100%; border-radius: 7px; object-fit: cover; }

.draft-photo .icon-button {
  position: absolute;
  top: 0;
  right: 0;
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.draft-photo svg { width: 15px; height: 15px; }

.event-status {
  position: fixed;
  z-index: 5;
  bottom: calc(var(--nav-bottom) + 70px);
  left: max(16px, calc((100% - 380px) / 2));
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 12px;
}

.gallery {
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--background);
  color: var(--text);
}

.gallery[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.gallery::backdrop { background: var(--background); }

.gallery-bar, .gallery-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
}

.gallery-bar { padding-top: max(12px, env(safe-area-inset-top)); }
.gallery-bar > div { display: flex; gap: 5px; }
.gallery-nav { justify-content: center; padding-bottom: max(12px, env(safe-area-inset-bottom)); }

.image-stage {
  display: grid;
  grid-template: 100% / 100%;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.image-stage img {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  will-change: transform;
  pointer-events: none;
}

@media (max-width: 440px) {
  .shell { width: calc(100% - 28px); }
  .timeline { --time-width: 35px; --marker-width: 32px; --column-gap: 7px; }
  .timeline time { font-size: 11px; }
  .event-card { padding: 9px 10px; }
  .event-title { font-size: 14px; }
}

