:root {
  --ink: #172a3a;
  --paper: #f3efe4;
  --paper-deep: #e8e0ce;
  --red: #d9472f;
  --blue: #2b6278;
  --line: rgba(23, 42, 58, .2);
  --muted: #667078;
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; background-color: var(--paper); background-image: linear-gradient(rgba(23,42,58,.035) 1px, transparent 1px); background-size: 100% 32px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.masthead { min-height: 260px; display: grid; grid-template-columns: 1fr minmax(280px, 560px) auto; align-items: end; gap: 44px; padding: 52px max(5vw, 24px) 36px; color: #f8f1e2; background: var(--ink); border-bottom: 9px solid var(--red); }
.brand { display: flex; gap: 17px; align-items: center; }
.brand-mark { width: 58px; height: 70px; display: grid; place-items: center; border: 1px solid #f8f1e2; border-radius: 50% 50% 45% 45%; font-size: 30px; font-style: italic; }
.eyebrow, .section-number, .dialog-kicker { margin: 0 0 7px; font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(40px, 5vw, 70px); font-weight: 400; line-height: .85; font-style: italic; }
.intro { max-width: 540px; margin: 0; font-size: 17px; line-height: 1.8; color: #d8d3c9; }
.top-count { display: flex; gap: 12px; align-items: end; font: 12px/1.45 ui-monospace, monospace; color: #d8d3c9; white-space: nowrap; }
.top-count strong { font: 400 66px/.75 Georgia, serif; color: #fff; }
main { width: min(1240px, calc(100% - 48px)); margin: 0 auto 80px; }
.entry-panel { position: relative; margin-top: 52px; padding: 24px 0 52px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.section-number { color: var(--red); }
#entryForm { display: grid; grid-template-columns: 1.4fr .8fr .8fr 1.2fr; gap: 24px 18px; margin-top: 20px; }
.form-heading { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
h2 { margin: 0; font-size: clamp(30px, 4vw, 48px); font-weight: 400; }
.form-heading p { color: var(--muted); margin: 0; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span, .filters label > span { font: 700 11px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
input, select, textarea { width: 100%; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; background: rgba(255,255,255,.28); padding: 13px 10px; outline: none; }
input:focus, select:focus, textarea:focus { background: #fffaf0; border-bottom: 3px solid var(--red); padding-bottom: 11px; }
textarea { resize: vertical; min-height: 48px; }
.note-field { grid-column: 1 / 4; position: relative; }
.note-field small { position: absolute; right: 7px; bottom: 7px; font: 10px ui-monospace, monospace; color: var(--muted); }
.form-error { grid-column: 1 / -1; min-height: 18px; color: #a62c20; font-size: 13px; }
.form-actions { grid-column: 4; grid-row: 4 / 6; display: flex; flex-direction: column; justify-content: end; gap: 8px; }
.primary { min-height: 58px; border: 0; background: var(--red); color: white; padding: 12px 20px; font: 700 14px ui-monospace, monospace; letter-spacing: .05em; }
.primary:hover { background: #b93422; }
.text-button, .quiet-button { border: 1px solid var(--line); background: transparent; padding: 9px 13px; font: 12px ui-monospace, monospace; }
.text-button:hover, .quiet-button:hover { border-color: var(--ink); background: rgba(255,255,255,.4); }
.archive { padding-top: 60px; }
.archive-head { display: flex; justify-content: space-between; align-items: end; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--ink); margin: 26px 0 28px; }
.stat { padding: 19px 22px; border-right: 1px solid var(--line); }
.stat:last-child { border: 0; }
.stat strong { display: block; font-size: 30px; font-weight: 400; }
.stat span { font: 11px ui-monospace, monospace; color: var(--muted); }
.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 14px; }
.filters label { display: flex; flex-direction: column; gap: 6px; }
.result-note { min-height: 20px; margin: 22px 0 8px; color: var(--muted); font: 12px ui-monospace, monospace; }
.timeline { position: relative; }
.date-group { display: grid; grid-template-columns: 180px 1fr; border-top: 1px solid var(--ink); }
.date-label { padding: 23px 20px 23px 0; }
.date-label time { position: sticky; top: 18px; display: block; }
.date-label b { display: block; font-size: 36px; font-weight: 400; }
.date-label span { color: var(--muted); font: 11px ui-monospace, monospace; }
.entries { border-left: 1px solid var(--line); }
.entry-card { position: relative; display: grid; grid-template-columns: minmax(150px, .8fr) minmax(180px, 1.5fr) auto; gap: 24px; padding: 24px 0 24px 28px; border-bottom: 1px dashed var(--line); }
.entry-card::before { content: ""; position: absolute; left: -5px; top: 31px; width: 9px; height: 9px; background: var(--red); transform: rotate(45deg); }
.place h3 { margin: 0 0 6px; font-size: 23px; font-weight: 400; overflow-wrap: anywhere; }
.visit-count { font: 10px ui-monospace, monospace; color: var(--red); text-transform: uppercase; }
.entry-note { margin: 0 0 12px; line-height: 1.55; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { padding: 4px 8px; background: var(--paper-deep); font: 11px ui-monospace, monospace; }
.tag.transport { color: white; background: var(--blue); }
.card-actions { display: flex; align-items: start; gap: 5px; }
.icon-button { border: 0; background: transparent; padding: 6px; color: var(--muted); font: 11px ui-monospace, monospace; }
.icon-button:hover { color: var(--red); text-decoration: underline; }
.empty-state { padding: 90px 20px; text-align: center; border-top: 1px solid var(--ink); }
.empty-state h3 { font-size: 28px; margin: 14px 0 8px; font-weight: 400; }
.empty-state p { color: var(--muted); }
.empty-compass { margin: auto; width: 72px; height: 72px; display: grid; place-items: center; border: 1px solid var(--ink); border-radius: 50%; font-size: 34px; }
dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 0; box-shadow: 0 20px 70px rgba(0,0,0,.3); background: var(--paper); }
dialog::backdrop { background: rgba(23,42,58,.65); }
dialog form { padding: 28px; border-top: 7px solid var(--red); }
dialog h3 { font-size: 27px; font-weight: 400; margin: 8px 0; }
dialog p { overflow-wrap: anywhere; }
dialog form > div { display: flex; justify-content: end; gap: 10px; margin-top: 24px; }
.danger-button { background: var(--red); border: 1px solid var(--red); color: white; padding: 9px 13px; }

@media (max-width: 800px) {
  .masthead { grid-template-columns: 1fr auto; gap: 30px; min-height: 0; padding-top: 34px; }
  .intro { grid-column: 1 / -1; grid-row: 2; }
  .top-count { grid-column: 2; grid-row: 1; }
  #entryForm { grid-template-columns: 1fr 1fr; }
  .form-heading, .location-field, .companions-field, .note-field, .form-error { grid-column: 1 / -1; }
  .form-actions { grid-column: 1 / -1; grid-row: auto; }
  .filters { grid-template-columns: 1fr 1fr; }
  .entry-card { grid-template-columns: 1fr auto; gap: 12px; }
  .entry-detail { grid-column: 1; }
  .card-actions { grid-column: 2; grid-row: 1; }
}
@media (max-width: 540px) {
  .masthead { display: block; padding: 28px 20px 25px; }
  .brand-mark { width: 43px; height: 54px; }
  .top-count { margin-top: 28px; }
  .intro { margin-top: 24px; }
  main { width: calc(100% - 30px); }
  .form-heading { display: block; }
  .form-heading p { margin-top: 10px; }
  #entryForm, .filters { grid-template-columns: 1fr; }
  .field, .location-field, .companions-field, .note-field { grid-column: 1; }
  .stats { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
  .date-group { grid-template-columns: 1fr; }
  .date-label { padding: 18px 0 10px; }
  .date-label time { position: static; display: flex; gap: 8px; align-items: baseline; }
  .date-label b { font-size: 25px; }
  .entries { border-left: 0; }
  .entry-card { padding-left: 18px; }
  .entry-card::before { left: 0; }
}
