/* Foundation: theme tokens, typography, forms, panels and accessibility utilities. */
* {
  box-sizing: border-box;
}

a:hover {
  color: var(--accent-dark);
}

.secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.compact {
  min-height: 40px;
  padding: 6px 13px;
  font-size: var(--text-sm);
}

.wide {
  width: 100%;
}

.danger {
  color: var(--error);
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

input[type="file"] {
  padding: 9px;
  max-width: 100%;
}

input[readonly] {
  background: transparent;
  border-style: dashed;
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 16px;
}

label input {
  margin-top: 5px;
  font-size: var(--text-base);
  font-weight: 400;
}

label textarea {
  margin-top: 5px;
  font-size: var(--text-base);
  font-weight: 400;
}

label select {
  margin-top: 5px;
  font-size: var(--text-base);
  font-weight: 400;
}

form {
  margin: 0;
}

fieldset {
  margin: 20px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  min-width: 0;
}

legend {
  font-weight: 650;
  padding: 0 5px;
}

p {
  margin-top: 0;
  margin-bottom: 16px;
}

.eyebrow {
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  font-weight: 750;
  margin-bottom: 10px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 650;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: var(--sand-150);
  color: var(--sand-700);
  line-height: 1.5;
}

.icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.panel {
  padding: 24px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading > a {
  font-size: var(--text-sm);
}

.delete-form {
  margin-top: 24px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 400;
}

.check input {
  margin: 0;
}

.sharing .hint {
  margin-bottom: 0;
}

.upload-panel {
  margin-bottom: 24px;
  max-width: 800px;
}

.upload-panel form {
  padding-top: 20px;
}

details[open] > summary {
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}

.reset-all {
  margin-bottom: 18px;
}

.custom-roll {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.custom-roll h2 {
  width: 100%;
  margin: 0;
}

.custom-roll label {
  margin: 0;
  max-width: 200px;
}

.custom-roll output {
  font-weight: 700;
}

.custom-roll .hint {
  width: 100%;
  margin: 0;
}

.action-editor-row {
  align-items: start;
}

.action-editor-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 12px;
  flex: 1;
}

.action-editor-fields .check {
  align-self: center;
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: var(--text-sm);
  font-weight: 600;
  padding-bottom: 5px;
}

.stat strong {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  line-height: 1.4;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  max-width: 950px;
}

.logout-form {
  margin-top: 24px;
}

.login-page {
  min-height: 100vh;
  background: var(--navy);
  padding: 44px 20px;
}

.login-card h1 {
  font-size: 2.8rem;
}

.login-card .eyebrow {
  color: var(--accent);
}

.login-map {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
  object-position: 50% 42%;
  border-radius: var(--radius-md);
  margin: 22px 0;
}

.login-card button {
  margin-top: 5px;
}

.login-card > .hint {
  margin-top: 18px;
  margin-bottom: 0;
}

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

.skip-link:focus {
  top: 10px;
}

@media (max-width: 700px) {
  .eyebrow {
    font-size: var(--text-2xs);
    margin-bottom: 9px;
  }
}

@media (max-width: 700px) {
  .panel {
    padding: 18px;
  }
}

@media (max-width: 700px) {
  .account-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .form-grid {
    gap: 0 12px;
  }
}

@media (max-width: 700px) {
  .stat {
    font-size: var(--text-sm);
  }
}

@media (max-width: 700px) {
  .action-editor-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .login-page {
    padding: 24px 16px;
  }
}

@media (max-width: 700px) {
  .login-card {
    padding: 26px;
  }
}

@media (max-width: 700px) {
  fieldset {
    padding: 13px;
  }
}

@media (max-width: 360px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

button:hover {
  background: var(--sand-50);
  color: var(--sand-900);
}

.button:hover {
  background: var(--sand-50);
  color: var(--sand-900);
}

button.secondary {
  color: inherit;
  border-color: var(--line);
  background: var(--paper);
}

.button.secondary {
  color: inherit;
  border-color: var(--line);
  background: var(--paper);
}

button:disabled {
  cursor: default;
  opacity: 0.5;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* Read-only: no fill and a dashed edge, legible on dark and parchment alike. */
.app-page input[readonly] {
  background: transparent;
  border-style: dashed;
  opacity: 1;
}

.plain-text {
  white-space: pre-wrap;
}

[hidden] {
  display: none !important;
}

.login-card {
  max-width: 470px;
  margin: auto;
  padding: 32px;
  border-radius: var(--radius-lg);
  background: var(--gray-850);
  color: var(--gray-100);
  border-color: #444;
}

body {
  margin: 0;
  letter-spacing: 0.005em;
}

h1 {
  margin-top: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 2.25rem;
  line-height: 1.15;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

h2 {
  margin-top: 0;
  font-size: var(--text-md);
  line-height: 1.35;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

h3 {
  font-size: var(--text-base);
  margin-top: 24px;
  text-wrap: balance;
}

.app-page h1 {
  letter-spacing: -0.025em;
  line-height: 1.12;
}

.app-page h2 {
  font-variant: small-caps;
  letter-spacing: 0.035em;
  line-height: 1.25;
}

.app-page h3 {
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.hint {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  -webkit-tap-highlight-color: transparent;
}

summary {
  cursor: pointer;
  font-weight: 650;
  min-height: 30px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 19px;
  border: 1px solid var(--accent);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.3;
  text-align: center;
  background: var(--sand-150);
  color: var(--sand-900);
  border-color: var(--sand-500);
  font-family: inherit;
  font-weight: 400;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-md);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 19px;
  border: 1px solid var(--accent);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.3;
  text-align: center;
  background: var(--sand-150);
  color: var(--sand-900);
  border-color: var(--sand-500);
  font-family: inherit;
  font-weight: 400;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-md);
}

button:not(:disabled):active {
  box-shadow: inset 0 2px 4px #0002;
}

.button:active {
  box-shadow: inset 0 2px 4px #0002;
}

.app-page input:hover {
  border-color: var(--gray-400);
}

.app-page select:hover {
  border-color: var(--gray-400);
}

.app-page textarea:hover {
  border-color: var(--gray-400);
}

button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

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

select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.app-page .panel {
  background: var(--gray-900);
  border: 1px solid #444;
  border-color: #ffffff18;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px #0002;
}

.app-page details.panel {
  background: var(--gray-900);
  border: 1px solid #444;
  border-color: #ffffff18;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px #0002;
}

.app-page .badge {
  background: var(--umber-700);
  color: var(--gold-200);
  border: 1px solid #ffffff12;
  border-radius: var(--radius-sm);
}

.app-page code {
  background: var(--gray-750);
  color: var(--sand-150);
}

input {
  font: inherit;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--gray-750);
  color: var(--gray-100);
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark;
}

select {
  font: inherit;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--gray-750);
  color: var(--gray-100);
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark;
}

textarea {
  font: inherit;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  background: var(--gray-750);
  color: var(--gray-100);
  min-width: 0;
  resize: vertical;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark;
}

input::placeholder {
  color: var(--gray-600);
  opacity: 1;
}

textarea::placeholder {
  color: var(--gray-600);
  opacity: 1;
}

.app-page input::placeholder {
  color: var(--gray-300);
}

.app-page textarea::placeholder {
  color: var(--gray-300);
}

.notice {
  background: var(--green-100);
  border: 1px solid #b7d6c7;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  --accent: var(--gold-700);
  --accent-dark: var(--gold-800);
  --error: var(--red-700);
  --ink: var(--green-800);
  --muted: #365344;
  color: var(--ink);
}

.notice.error {
  background: var(--red-100);
  border-color: #e9b9ae;
  --ink: var(--red-700);
  --muted: var(--red-700);
  color: var(--ink);
}

code {
  font-size: 0.875em;
  background: var(--sand-150);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  overflow-wrap: anywhere;
  color: var(--gray-900);
}

button.danger {
  color: var(--red-700);
}

.button.danger {
  color: var(--red-700);
}

button.secondary.danger {
  color: var(--error);
}

.button.secondary.danger {
  color: var(--error);
}

.secondary:hover {
  color: var(--ink);
  background: var(--tint);
}

@media (max-width: 600px) {
  :root {
    --footer-height: 92px;
    --header-height: 78px;
  }
}

:root {
  --navy: #1b1b1b;
  --line: #505050;
  --accent: #e6ce78;
  --accent-dark: #d1b84e;
  --radius: 12px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: #0d0d0d;
  font-size: 16px;
  line-height: 1.55;
  --header-height: 74px;
  --footer-height: 96px;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  scrollbar-width: thin;
  scrollbar-color: #68645d #141414;
  --error: #ffaaa2;
  --surface-page: #0d0d0d;
  --surface-panel: #191919;
  --surface-inset: #242424;
  --text-primary: #eee;
  --text-muted: #bdbdbd;
  --control-border: #888;
  --focus-ring: #ddc65d;
  --ink: var(--text-primary);
  --muted: var(--text-muted);
  --paper: var(--surface-panel);
  --ground: var(--surface-page);
  --tint: var(--surface-inset);
  --motion-fast: 140ms;
  --motion-enter: 180ms;
  --motion-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  /* Shared palette. The app is a neutral dark table (gray), parchment sheets on
     top of it (sand), gold accents, and red/green/violet for meaning. Components
     use these steps instead of their own near-identical shades. */
  --gray-950: #0d0d0d;
  --gray-900: #171717;
  --gray-850: #1b1b1b;
  --gray-800: #242424;
  --gray-750: #292929;
  --gray-700: #333;
  --gray-600: #555;
  --gray-500: #777;
  --gray-400: #888;
  --gray-300: #bdbdbd;
  --gray-200: #d9d9d9;
  --gray-100: #eee;
  --white: #fff;
  --sand-50: #fffdf7;
  --sand-100: #f6f4ef;
  --sand-150: #eee8d8;
  --sand-200: #e6e3dc;
  --sand-300: #d3d0c9;
  --sand-400: #c9c3b7;
  --sand-500: #aba18e;
  --sand-600: #62594a;
  --sand-700: #514b3e;
  --sand-800: #343025;
  --sand-900: #29251d;
  --umber-900: #1f1c18;
  --umber-800: #28241e;
  --umber-700: #302921;
  --gold-200: #eee4cc;
  --gold-300: #e6ce78;
  --gold-400: #d1b84e;
  --gold-700: #51421b;
  --gold-800: #3b3014;
  --red-100: #f3e6e3;
  --red-300: #ffaaa2;
  --red-700: #792d22;
  --green-100: #e3ebe4;
  --green-800: #203d30;
  --violet-600: #695285;
  /* Shape and type scales. */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-ui: system-ui, sans-serif;
  --font-mono: ui-monospace, Consolas, monospace;
  --text-2xs: 0.72rem;
  --text-xs: 0.78rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.15rem;
  --text-lg: 1.3rem;
  --text-xl: 1.6rem;
  --text-2xl: 1.85rem;
}

.app-page {
  background: var(--surface-page);
  color: var(--text-primary);
}

.app-page input {
  background: var(--gray-750);
  color: var(--gray-100);
  border-radius: var(--radius-md);
  color-scheme: dark;
  border-color: var(--control-border);
}

.app-page select {
  background: var(--gray-750);
  color: var(--gray-100);
  border-radius: var(--radius-md);
  color-scheme: dark;
  border-color: var(--control-border);
}

.app-page textarea {
  background: var(--gray-750);
  color: var(--gray-100);
  border-radius: var(--radius-md);
  color-scheme: dark;
  border-color: var(--control-border);
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 20px;
  background: white;
  padding: 12px;
  z-index: 200;
  color: #171717;
  --focus-ring: #695285;
}

.skip-link:hover {
  color: #171717;
  background: #fff;
}
