:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #15171c;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --danger: #c92a2a;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #181b22;
    --text: #e8eaf0;
    --muted: #8b93a7;
    --border: #2a2f3a;
    --accent: #748ffc;
    --accent-text: #0f1115;
    --danger: #ff6b6b;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #181b22;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --border: #2a2f3a;
  --accent: #748ffc;
  --accent-text: #0f1115;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

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

h1, h2 { margin: 0 0 0.5rem; line-height: 1.2; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.session { display: flex; align-items: center; gap: 0.75rem; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-width: 0;
}

.narrow { max-width: 420px; justify-self: center; width: 100%; }

.stack { display: grid; gap: 0.85rem; }
.stack label, label { display: grid; gap: 0.3rem; font-size: 0.9rem; }

input, select, button, .button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  color: var(--text);
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button, .button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

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

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: 500;
}

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
}

button.link:disabled { color: var(--text); opacity: 1; }

.button { display: inline-block; position: relative; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline { display: flex; gap: 0.5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.6rem; margin-top: 1rem; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }

table { width: 100%; border-collapse: collapse; }
.entries th, .entries td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.entries th { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.entries td { overflow-wrap: anywhere; }
.right { text-align: right; }

.plain { list-style: none; padding: 0; margin: 0; }
.share-row { display: grid; gap: 0.2rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.share-row:last-child { border-bottom: none; }
code { font: 0.85rem ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

dialog {
  width: min(440px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem;
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }

.share-result {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.share-result code { flex: 1; }

.notice {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.notice.error { border-color: var(--danger); color: var(--danger); }

.muted { color: var(--muted); font-size: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Public share pages */
body:has(.share) { display: grid; place-items: start center; min-height: 100vh; }
.share { width: min(640px, calc(100vw - 2rem)); margin-top: 3rem; }

@media (max-width: 560px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .inline { flex-wrap: wrap; }
  .entries .muted:nth-child(3) { display: none; }
}
