:root {
  --bg: #faf8f5;
  --fg: #1f1d1a;
  --muted: #6b665e;
  --accent: #8a3b12;
  --accent-fg: #fff;
  --border: #ddd6cc;
  --panel: #fff;
  --error-bg: #fdecea;
  --error-fg: #8a1c12;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --fg: #ece7e0;
    --muted: #a39c92;
    --accent: #e08a4e;
    --accent-fg: #1a1816;
    --border: #3b3631;
    --panel: #23201d;
    --error-bg: #3d1c18;
    --error-fg: #ffb4a8;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

main { max-width: 960px; margin: 0 auto; padding: 1rem 16px 3rem; }

.site-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem;
  padding: .75rem 16px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.site-header .brand { font-weight: 700; text-decoration: none; color: var(--fg); font-size: 1.15rem; }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-left: auto; }
.search-mini input { width: 14rem; max-width: 100%; }
/* Phones: keep the nav on one row; the name is still shown on "My tables". */
@media (max-width: 479px) {
  .site-header .who { display: none; }
  .site-header nav { gap: .6rem; margin-left: 0; }
}

.muted { color: var(--muted); }
.warning { color: var(--error-fg); }
.inline { display: inline; }

input[type=text], input[type=password], input[type=search] {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); color: var(--fg); width: 100%;
}

button, .button {
  font: inherit; display: inline-block; padding: .45rem 1rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); text-decoration: none;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }

.stack { display: flex; flex-direction: column; gap: .9rem; max-width: 640px; }
.stack label { display: flex; flex-direction: column; gap: .25rem; }
.stack > button { align-self: flex-start; }
.stack label.check { flex-direction: row; align-items: flex-start; gap: .6rem; }
.stack label.check input { margin: .3rem 0 0; flex: none; }
.stack label.check small { display: block; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; }
.entry-inputs { margin: 0; padding-left: 2.5rem; }
.entry-inputs li { margin: .25rem 0; }

textarea {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); color: var(--fg); width: 100%; resize: vertical;
}
code { font-size: .9em; background: var(--border); border-radius: 4px; padding: 0 .25em; }

.import { border: 1px dashed var(--border); border-radius: 8px; padding: .5rem 1rem; }
.import[open] { padding-bottom: 1rem; }
.import summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: .25rem 0; }
.import textarea { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.import-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .5rem; }
.stack .import-actions label.file { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
.import-actions input[type=file] { font: inherit; font-size: .9rem; max-width: 100%; }
.import-result:empty { display: none; }
.import-result { margin-top: .75rem; padding: .25rem .9rem; border-radius: 8px; border: 1px solid var(--border); }
.import-result p { margin: .4rem 0; }
.import-result.ok { border-color: var(--accent); }
.import-result.error { background: var(--error-bg); color: var(--error-fg); border-color: transparent; }

.errors { background: var(--error-bg); color: var(--error-fg); border-radius: 8px; padding: .5rem 1rem; margin: 0 0 1.25rem; max-width: 640px; }

.columns { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 760px) { .columns { grid-template-columns: 3fr 2fr; } }

.entries { padding-left: 2.5rem; }
.entries li { padding: .1rem 0; overflow-wrap: anywhere; }

.roller { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 0 1rem 1rem; align-self: start; }
.roll-results { padding-left: 2rem; max-height: 60vh; overflow-y: auto; }
.roll-results li { padding: .15rem 0; overflow-wrap: anywhere; }
.roll-results li:first-child { font-size: 1.1rem; }

.versions ul { list-style: none; padding-left: 1.25rem; border-left: 1px dashed var(--border); }
.versions > ul { padding-left: 0; border-left: none; }
.versions li { margin: .25rem 0; }

.table-list { padding-left: 1.25rem; }
.table-list li { margin: .35rem 0; }

.my-tables { list-style: none; padding: 0; margin: 0; max-width: 760px; }
.my-tables li {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .7rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere;
}
.my-tables li:first-child { border-top: 1px solid var(--border); }
.my-tables .name { font-weight: 600; font-size: 1.05rem; }

.favorite { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; margin: 0 0 1rem; }
.favorite form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; }
.fav-on { color: var(--accent); font-weight: 600; }
.my-tables form { margin-top: .15rem; }

.search-form { display: flex; gap: .5rem; max-width: 640px; }
