:root {
  --snow: #e4ebf0;
  --ridge: #1c333c;
  --paper: #f3eee4;
  --seal: #c5341f;
  --ink: #1a2428;
  --mist: #3a4c54;
  --rule: #d9d0c2;
  --display: "Songti SC", "STSong", "SimSun", serif;
  --text: "STFangsong", "FangSong", "Songti SC", serif;
  --num: "DIN Alternate", "DIN Condensed", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --chop: "Kaiti SC", "STKaiti", "KaiTi", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--snow);
  background-image: url("/ridge.svg");
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: 100% 46vh;
  font-family: var(--text);
  font-size: 18px;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--ridge);
}

h1, h2, p, ul, ol, dl, figure, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

button, input { font: inherit; color: inherit; }

::selection { background: var(--seal); color: var(--paper); }

.desk {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 36px;
  align-items: start;
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 32px 88px;
}

.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  position: sticky;
  top: 16px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 4px 0;
  background: var(--snow);
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
  align-items: center;
}

.topnav form { margin: 0; }

.whoami {
  font-family: var(--display);
  letter-spacing: 0.04em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1.5px solid var(--ridge);
  background: var(--paper);
  color: var(--ridge);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover,
.btn[aria-current="page"] {
  background: var(--ridge);
  color: var(--paper);
}

.btn.small {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 15px;
}

.btn.danger {
  border-color: #9e2a1c;
  background: transparent;
  color: #9e2a1c;
}

.btn.danger:hover {
  background: #9e2a1c;
  color: var(--paper);
}

.sheet-page {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 32px 88px;
}

.sheet-page .topbar { position: sticky; top: 16px; }

.sheet-page .logbook {
  grid-column: auto;
  width: min(640px, 100%);
  margin: 28px auto 0;
}

.panel { grid-column: 1; grid-row: 2; position: sticky; top: 76px; }
.logbook { grid-column: 2; grid-row: 2; }

.eyebrow, .sheet-kicker {
  font-family: var(--num);
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--mist);
}

.station-name {
  margin-top: 8px;
  font-family: var(--display);
  font-size: clamp(56px, 7vw, 88px);
  line-height: 1.02;
  letter-spacing: 0.06em;
  color: var(--ridge);
}

.lede {
  max-width: 16em;
  margin-top: 14px;
  font-size: 20px;
  line-height: 1.55;
}

.meter { margin-top: 28px; }

.dial { width: min(240px, 100%); height: auto; display: block; }

.needle {
  transform-box: view-box;
  transform-origin: 110px 108px;
  animation: settle 1.1s cubic-bezier(0.16, 0.84, 0.32, 1) both;
}

.meter figcaption {
  margin-top: 2px;
  color: var(--mist);
}

.num {
  font-family: var(--num);
  font-style: normal;
  letter-spacing: 0.03em;
}

.readings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
  margin-top: 26px;
}

.readings div {
  border-top: 1px solid rgba(28, 51, 60, 0.22);
  padding-top: 8px;
}

.readings dt {
  font-size: 16px;
  color: var(--mist);
}

.readings dd {
  margin-top: 2px;
  font-family: var(--num);
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--ridge);
}

.logbook {
  position: relative;
  background: var(--paper);
  padding: 36px 32px 28px;
  box-shadow: 8px 10px 0 var(--ridge);
}

.chop {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 88px;
  height: 88px;
  border: 3px solid var(--seal);
  border-radius: 50%;
  color: var(--seal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotate(12deg);
  font-family: var(--chop);
  font-size: 18px;
  line-height: 1.05;
  letter-spacing: 0.14em;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.chop::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid var(--seal);
  border-radius: 50%;
}

.chop span { display: block; }

.sheet-title {
  margin-top: 10px;
  padding-right: 104px;
  font-family: var(--display);
  font-size: clamp(36px, 4vw, 48px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.04em;
}

.sheet-date, .role {
  margin-top: 6px;
  color: var(--mist);
}

.duty {
  margin-top: 14px;
  font-size: 18px;
  line-height: 1.6;
}

.error {
  margin-top: 18px;
  padding-left: 10px;
  border-left: 3px solid var(--seal);
  color: #9e2a1c;
}

.login-form { margin-top: 8px; }

.field { margin-top: 18px; }

.field label {
  display: block;
  margin-bottom: 4px;
  color: var(--mist);
  font-size: 16px;
  letter-spacing: 0.16em;
}

input {
  width: 100%;
  height: 40px;
  padding: 0;
  border: 0;
  border-bottom: 1.5px solid var(--ridge);
  border-radius: 0;
  background: transparent;
  font-family: var(--num);
  font-size: 22px;
  line-height: 40px;
  letter-spacing: 0.04em;
  appearance: none;
}

input:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 4px;
}

input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--paper) inset;
  -webkit-text-fill-color: var(--ink);
}

.submit {
  margin-top: 28px;
  padding: 12px 22px;
  border: 0;
  background: var(--ridge);
  color: var(--paper);
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.submit:hover { background: #234e43; }

.submit:focus-visible,
.fill:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 3px;
}

.submit:active { transform: translateY(1px); }

.accounts { margin-top: 28px; }

.accounts > p {
  font-family: var(--num);
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--mist);
}

.accounts li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "who fill"
    "codes fill";
  align-items: center;
  gap: 2px 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}

.who { grid-area: who; }
.codes { grid-area: codes; display: flex; gap: 12px; }
.fill { grid-area: fill; }

code {
  font-family: var(--num);
  font-size: 18px;
}

.fill {
  padding: 4px 10px;
  border: 1px solid var(--ridge);
  background: transparent;
  color: var(--ridge);
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.fill:hover { background: var(--ridge); color: var(--paper); }

.log-title {
  margin-top: 28px;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.entries { margin-top: 8px; }

.entries li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.when { font-family: var(--num); letter-spacing: 0.04em; }
.facts { display: flex; gap: 16px; font-family: var(--num); }
.note, .by, .entry-actions { grid-column: 1 / -1; }
.note { color: var(--mist); }
.by { color: var(--mist); font-size: 15px; }

.entry-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}

.entry-actions form,
.page-actions form { margin: 0; }

.memo-name {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.04em;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

.record-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-top: 8px;
}

.record-form .field { margin-top: 0; }
.record-form .note-field,
.record-form .form-actions { grid-column: 1 / -1; }
.record-form .submit { margin-top: 8px; }

.form-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}

.back-row { margin-top: 22px; }

.back {
  color: var(--ridge);
  font-family: var(--display);
  letter-spacing: 0.08em;
}

.solo {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 16px 72px;
}

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

.solo .logbook {
  grid-column: auto;
  width: min(460px, 100%);
}

.login-sheet { padding: 40px 36px 36px; }

@keyframes settle {
  from { transform: rotate(-36deg); }
  to { transform: rotate(28deg); }
}

@media (max-width: 800px) {
  .desk {
    grid-template-columns: 1fr;
    width: min(640px, calc(100% - 32px));
    padding: 28px 0 56px;
    gap: 28px;
  }

  .topbar { top: 12px; align-items: flex-start; flex-direction: column; }
  .topnav { width: 100%; justify-content: flex-start; }
  .sheet-page { padding: 28px 16px 56px; }
  .panel, .logbook {
    grid-column: auto;
    grid-row: auto;
    position: static;
  }

  .station-name { font-size: 48px; }
  .readings dd { font-size: 26px; }
  .logbook {
    padding: 28px 20px 22px;
    box-shadow: 5px 6px 0 var(--ridge);
  }

  .record-form { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .chop { width: 70px; height: 70px; font-size: 16px; top: 14px; right: 12px; }
  .sheet-title { padding-right: 76px; font-size: 32px; }
  .codes { flex-direction: column; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .needle { animation: none; transform: rotate(28deg); }
  .submit:active { transform: none; }
}
