* { box-sizing: border-box; }

:root {
  color-scheme: dark;
  --coffee: #211e1a;
  --cream: #f4ede2;
  --tan: #bda07b;
  --panel: #37322c;
  --line: #61564a;
  --danger: #ffc0b1;
  --dock-height: 66px;
  font-family: system-ui, "Microsoft JhengHei", sans-serif;
}

body {
  margin: 0;
  background: #171512;
  color: var(--cream);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.app {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  background: var(--coffee);
}

.brand, main {
  padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right));
}

.brand {
  display: grid;
  justify-items: start;
  padding-block: calc(12px + env(safe-area-inset-top)) 15px;
  border-bottom: 1px solid var(--line);
}

.brand-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font: 700 1.65rem Georgia, serif;
}

.brand span, .muted, .record span, small, dt { color: #d7c3a8; }

main { padding-block: 22px calc(var(--dock-height) + env(safe-area-inset-bottom) + 24px); }

h1, h2, p, dl, ul { margin: 0; }
h1 { font-size: 1.65rem; line-height: 1.25; margin-bottom: 16px; }
h2 { font-size: 1.05rem; margin-bottom: 10px; }
main > section + section { margin-top: 22px; }
a { color: inherit; text-decoration: none; }

.card {
  max-width: 100%;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.heading, .summary, .actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.heading, .summary { justify-content: space-between; }
.heading { margin-bottom: 16px; }
.heading h1 { margin: 0; }
.summary strong {
  display: block;
  color: var(--tan);
  font: 700 2.6rem Georgia, serif;
}

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 13px;
  color: var(--cream);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.primary { background: var(--tan); border-color: var(--tan); color: var(--coffee); }
.danger { border-color: #a26d60; color: var(--danger); }

:focus-visible { outline: 2px solid #fff0ce; outline-offset: 3px; }
@media (hover: hover) {
  .button:hover, button:hover, .record:hover { box-shadow: inset 0 0 0 1px currentColor; }
}

.records { display: grid; gap: 9px; padding: 0; list-style: none; }
.record { display: grid; min-height: 44px; }
.back { display: inline-flex; min-height: 44px; align-items: center; color: var(--tan); }
.properties dt { font-size: .875rem; }
.properties dd { margin: 0 0 12px; white-space: pre-wrap; }
.properties dd:last-child { margin-bottom: 0; }
.properties + .actions, form:not(.editor) .actions { margin-top: 16px; }

.editor, .field { display: grid; gap: 7px; min-width: 0; }
.editor { gap: 15px; }
input:not([type=hidden]), textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  background: var(--coffee);
  color: var(--cream);
  border: 1px solid #8a7864;
  border-radius: 8px;
  font: inherit;
  font-size: max(16px, 1rem);
}
textarea { resize: vertical; }
input[type=date], input[type=datetime-local], select { max-width: 100%; }
.time-fields {
  margin: 0;
  padding: 8px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.time-fields legend { padding-inline: 4px; }
.notice {
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--tan);
  border-radius: 8px;
}
.error { color: var(--danger); border-color: var(--danger); }

.editor + section { margin-top: 22px; }
.comparison-note { margin-top: 12px; }
.score-comparison dd { display: flex; align-items: center; gap: 8px; }
.score-comparison meter { width: min(65%, 160px); min-width: 0; }
.form-caption { margin-bottom: 12px; }
.detail-actions { margin-top: 16px; }
.radar { display: block; margin: 0 auto 12px; width: 100%; max-width: 290px; }
.radar-grid { fill: none; stroke: #8a7864; }
.radar-score { fill: var(--tan); fill-opacity: .35; stroke: var(--cream); stroke-width: 2; }
.radar text { fill: var(--cream); font-size: 10px; }

.dock {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: calc(var(--dock-height) + env(safe-area-inset-bottom));
  padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.dock a {
  display: grid;
  min-height: 44px;
  place-content: center;
  text-align: center;
  border-radius: 8px;
  font-size: .875rem;
}
.dock a[aria-current] { background: var(--tan); color: var(--coffee); font-weight: 700; }
body { scroll-padding-bottom: calc(var(--dock-height) + env(safe-area-inset-bottom)); }

