:root {
  --bg: #f4efe6;
  --fg: #1c1915;
  --muted: #6b645b;
  --card: #fffdf8;
  --line: #e4dcd0;
  --accent: #c45c26;
  --accent-fg: #fffaf6;
  --danger: #9b2c2c;
  --ok: #2f6b4f;
  --shadow: 0 10px 30px rgb(28 25 21 / 8%);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  max-width: 54rem;
  margin: 0 auto;
}
.page { display: block; }
.sidenav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 1rem 0 0;
}
.sidenav button {
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}
@media (min-width: 800px) {
  .page:has(#sidenav:not([hidden])) {
    display: grid;
    grid-template-columns: 11.5rem minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
  }
  .sidenav {
    position: sticky;
    top: 1rem;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    margin-top: 1.15rem;
  }
  .sidenav button { text-align: left; }
}
.top h1 { font-size: 1.85rem; font-weight: 600; margin: 0 0 0.35rem; letter-spacing: -0.02em; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.top-actions { display: flex; align-items: center; gap: 0.45rem; flex: none; }
.lang, .who {
  font: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  flex: none;
}
.who { max-width: 8.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
.who.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.top p, .muted, #run-blurb, #detail-desc { color: var(--muted); margin: 0; }
#view-login, #view-setup { max-width: 26rem; margin-inline: auto; }
.view { animation: in 0.25s ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cards { display: grid; gap: 0.85rem; margin-top: 1.25rem; }
.card, .sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  box-shadow: var(--shadow);
}
.card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 1.15rem 1.2rem 1.2rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.card h3 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.98rem; }
.card:active { transform: scale(0.99); }
.sheet { padding: 1.2rem; margin: 1rem 0; }
.sheet h2 { margin: 0 0 0.4rem; font-size: 1.35rem; }
label { display: block; margin: 1rem 0 0.35rem; font-size: 0.95rem; }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), select {
  width: 100%;
  font: inherit;
  padding: 0.75rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: #fff;
}
textarea {
  width: 100%;
  font: inherit;
  padding: 0.85rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: #fff;
  min-height: 6.5rem;
}
.primary, .download, .danger, .back {
  font: inherit;
  border: 0;
  cursor: pointer;
}
.primary, .download {
  display: block;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  text-align: center;
  text-decoration: none;
  font-size: 1.05rem;
}
.primary:disabled { opacity: 0.55; }
.danger {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem;
  border-radius: 999px;
  background: #f6e6e4;
  color: var(--danger);
}
.back {
  background: none;
  color: var(--accent);
  padding: 0.2rem 0 0.8rem;
  font-size: 0.95rem;
}
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty p { color: var(--muted); margin-bottom: 1rem; }
.drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 7.5rem;
  border: 1.5px dashed var(--accent);
  border-radius: 1rem;
  background: #fff8f3;
  text-align: center;
  padding: 1rem;
  color: var(--fg);
}
.drop input { display: none; }
.drop.on { background: #fde8d8; }
.status { margin-top: 0.85rem; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.status.busy { color: var(--muted); }
.search {
  width: 100%;
  font: inherit;
  padding: 0.75rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: #fff;
  margin-top: 1.1rem;
  -webkit-appearance: none;
}
.result-title { margin: 1.1rem 0 0.4rem; font-size: 1.05rem; }
.logout {
  font: inherit;
  display: block;
  margin: 1.5rem auto 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
.switch { position: relative; display: inline-block; width: 3rem; height: 1.8rem; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #ddd3c4;
  transition: background 0.15s ease;
  pointer-events: none;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(28 25 21 / 25%);
  transition: transform 0.15s ease;
}
.switch input:checked + .knob { background: var(--ok); }
.switch input:checked + .knob::after { transform: translateX(1.2rem); }
.switch input:disabled + .knob { opacity: 0.45; }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  margin: 0.15rem 0 0.6rem;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #fff;
}
.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  cursor: pointer;
}
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.section-title { margin: 1rem 0 0; font-size: 1.35rem; }
.upload-form { margin-top: 1rem; }
.wide { display: block; width: 100%; margin-top: 0.75rem; padding: 0.7rem; }
.manage-list { list-style: none; padding: 0; margin: 0.75rem 0 0; display: grid; gap: 0.65rem; }
.manage-list li {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem 0.9rem;
}
.manage-list .grow { flex: 1; min-width: 0; }
.manage-list strong { display: block; }
.manage-list span { color: var(--muted); font-size: 0.9rem; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.row h2 { margin: 0; }
.ghost-link, .secondary {
  font: inherit;
  text-decoration: none;
  color: var(--accent);
}
.ghost-link { font-size: 0.95rem; white-space: nowrap; }
.secondary {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: #fff8f3;
  text-align: center;
}
.ghost {
  font: inherit;
  background: #efe8dc;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}
details { margin-top: 1rem; }
summary { cursor: pointer; color: var(--muted); }
pre {
  white-space: pre-wrap;
  font-size: 0.78rem;
  line-height: 1.4;
  background: #f7f1e8;
  padding: 0.75rem;
  border-radius: 0.75rem;
  overflow: auto;
}
.tabs[hidden], .tab[hidden] { display: none; }
.tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 1.15rem auto 0;
  padding: 0.22rem;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 70%, var(--bg));
}
.tab {
  font: inherit;
  border: 0;
  background: transparent;
  padding: 0.5rem 1.15rem;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.on { background: var(--fg); color: var(--bg); }
.sidenav[hidden], .edit-page[hidden] { display: none !important; }
body.editing { max-width: none; padding: 0; }
body.editing .top,
body.editing .page { display: none !important; }
.edit-page {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 0.7rem 0.8rem 0.8rem;
  background: var(--bg);
  min-height: 0;
}
.edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.edit-toolbar-meta { min-width: 0; }
.edit-toolbar-meta strong { word-break: break-all; font-size: 0.95rem; }
.edit-toolbar-actions { display: flex; gap: 0.5rem; flex: none; }
.edit-test {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.5rem;
}
.edit-test label { margin: 0; }
.edit-test select { flex: 1; min-width: 10rem; }
.edit-test .primary { width: auto; margin: 0; padding: 0.55rem 1rem; }
#ed-run-out { margin-bottom: 0.5rem; max-height: 10rem; overflow: auto; }
.edit-toolbar-actions .primary,
.edit-toolbar-actions .secondary { width: auto; margin: 0; padding: 0.55rem 1rem; }
.editor {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  min-height: 20rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: hidden;
  background: #fff;
}
.editor-full { flex: 1; min-height: 0; }
.tree-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f7f1e8;
  min-height: 0;
}
.tree { flex: 1; overflow: auto; padding: 0.35rem 0; }
.tree button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.8rem;
  border: 0;
  background: none;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  color: var(--fg);
}
.tree button.on { background: #fff; }
.tree .dir { color: var(--muted); cursor: pointer; }
.tree-actions { display: flex; gap: 0.3rem; padding: 0.4rem; border-top: 1px solid var(--line); }
.tree-actions .ghost { flex: 1; padding: 0.35rem; font-size: 0.8rem; }
#ed-text {
  min-height: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}
.editor .CodeMirror { height: 100%; font-size: 0.8rem; }
.ed-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  background: #f7f1e8;
}
.ed-preview img, .ed-preview video { max-width: 100%; max-height: 100%; }
.ed-preview audio { width: min(28rem, 100%); }
.ed-preview .ph { color: var(--muted); font-size: 1.05rem; }
@media (max-width: 640px) {
  .editor { grid-template-columns: 1fr; }
  .tree-col { min-height: 0; max-height: 8.5rem; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (min-width: 720px) {
  body { padding-top: 2rem; }
}
