:root {
  --accent: #0f7f73;
  --accent-soft: #e3f3f1;
  --text: #1f2933;
  --muted: #5b6773;
  --border: #cfd6dd;
  --surface: #ffffff;
  --background: #f3f5f7;
  --bar: #262b30;
  --danger: #b42318;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--background);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bar); color: #fff;
}
#edition { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
#refresh { background: none; border: 0; color: #fff; font-size: 22px; padding: 4px 8px; min-height: 0; width: auto; }

#status { font-size: 13px; color: var(--muted); padding: 6px 16px 0; min-height: 22px; }

main { padding: 8px 16px 24px; max-width: 760px; margin: 0 auto; }

h1 { font-size: 26px; margin: 8px 0; }
h2 { font-size: 22px; margin: 8px 0 12px; }
h3 { font-size: 16px; margin: 20px 0 8px; }

button, .action {
  font: inherit; min-height: 48px; border-radius: 10px; cursor: pointer;
}
button.primary {
  background: var(--accent); color: #fff; border: 1px solid var(--accent); font-weight: 600;
  padding: 12px 20px; width: 100%;
}
button.secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 12px 20px; width: 100%; margin-top: 8px;
}
button.wide { margin-bottom: 12px; }

.welcome { text-align: center; padding-top: 24px; }
.welcome img { border-radius: 20px; }
.welcome p { color: var(--muted); }
.welcome .payoff { margin-top: 0; font-style: italic; }
.welcome .link { display: inline-block; margin-top: 18px; color: var(--accent); }
.hint { font-size: 14px; margin-top: 24px; }
.error { color: var(--danger) !important; }
.muted { color: var(--muted); font-weight: normal; }
.center { text-align: center; }

input[type="search"] {
  width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; min-height: 48px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
input[type="search"]:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.count { color: var(--muted); font-size: 14px; margin: 8px 2px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.list li + li { border-top: 1px solid var(--border); }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%;
  text-align: left; background: none; border: 0; padding: 12px 14px; color: inherit; min-height: 56px; border-radius: 0;
}
.row .title { font-weight: 600; grid-column: 1; }
.row .sub { color: var(--muted); font-size: 14px; grid-column: 1; }
.row .price { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 600; white-space: nowrap; }
button.row:active { background: var(--accent-soft); }

.back { background: none; border: 0; color: var(--accent); padding: 8px 0; min-height: 40px; font-weight: 600; }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.action {
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; border: 1px solid transparent;
}

.details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px; margin: 16px 0 0; }
.details dt { color: var(--muted); font-size: 13px; margin-top: 10px; }
.details dd { margin: 2px 0 10px; white-space: pre-wrap; }

nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 2;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav[hidden] { display: none; }
nav button { flex: 1; background: none; border: 0; border-radius: 0; color: var(--muted); font-weight: 600; min-height: 56px; }
nav button.active { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

button.new { margin: 10px 0 0; }
.badge {
  display: inline-block; justify-self: start; grid-column: 1; margin-top: 4px;
  font-size: 12px; font-weight: 600; color: #8a4b00; background: #fff1db; border-radius: 6px; padding: 2px 8px;
}
p.badge { margin: 0 0 12px; }

form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.field[hidden] { display: none; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 17px; color: var(--text); padding: 10px 12px; min-height: 48px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
