:root {
  --navy: #000080;
  --teal: #008080;
  --silver: #c0c0c0;
  --yellow: #ffff00;
}
* { box-sizing: border-box; }
body {
  font-family: Verdana, Geneva, 'Comic Sans MS', system-ui, sans-serif;
  background: var(--teal);
  color: #000;
  margin: 0;
  padding: 0;
}
a { color: var(--navy); }
header.site {
  background: var(--navy);
  color: #fff;
  padding: 0.6rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
header.site .brand { font-weight: bold; font-size: 1.2rem; }
header.site nav { display: flex; gap: 0.8rem; margin-left: auto; flex-wrap: wrap; }
header.site nav a { color: var(--yellow); text-decoration: none; }
header.site nav a:hover { text-decoration: underline; }
.lang-switch { display: inline-flex; gap: 0.25rem; align-items: center; font-size: 0.85rem; }
.lang-switch a { color: var(--yellow); }
.lang-switch strong { color: #fff; }
main {
  max-width: 900px;
  margin: 1.5rem auto;
  background: var(--silver);
  border: 3px outset #fff;
  padding: 1.5rem;
}
h1, h2 { color: var(--navy); }
.card {
  background: #fff;
  border: 2px inset var(--silver);
  padding: 1rem;
  margin: 1rem 0;
}
input, textarea, select {
  font-family: inherit;
  padding: 0.35rem;
  border: 2px inset var(--silver);
  width: 100%;
  max-width: 28rem;
}
textarea { min-height: 16rem; width: 100%; max-width: 100%; font-family: 'Courier New', monospace; }
button {
  font-family: inherit;
  padding: 0.4rem 1rem;
  border: 2px outset #fff;
  background: var(--silver);
  cursor: pointer;
}
button:active { border-style: inset; }
.quota-bar { background: #fff; border: 1px solid #000; height: 1.2rem; max-width: 28rem; }
.quota-bar > span { display: block; height: 100%; background: var(--navy); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 60px; max-width: 28rem; margin: 0.5rem 0; border-bottom: 2px solid var(--navy); }
.spark-bar { flex: 1 1 auto; min-width: 2px; background: var(--navy); }
.file-tree a { display: block; padding: 0.15rem 0; font-family: 'Courier New', monospace; }
.msg-ok { color: #060; } .msg-err { color: #900; }
.notice-mod { border: 3px solid #900; background: #fff0f0; }
.notice-mod h2 { color: #900; }
.notice-item { border-bottom: 1px solid var(--silver); padding-bottom: 0.4rem; margin-bottom: 0.4rem; }
.admin-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.admin-actions form { display: inline; }

/* Info dialogs — pure-CSS :target modal (no JS; works under script-src 'self'). */
.modal-open { display: inline-block; cursor: pointer; font-weight: bold; }
.modal { display: none; position: fixed; inset: 0; z-index: 100; }
.modal:target { display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 32, 0.55); }
.modal-box { position: relative; z-index: 1; background: var(--silver); border: 3px outset #fff;
  padding: 1rem 1.25rem; max-width: 34rem; max-height: 85vh; overflow: auto; margin: 1rem;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.4); }
.modal-box h3 { color: var(--navy); margin-top: 0; }
.modal-box ul { margin: 0.5rem 0; }
.modal-x { position: absolute; top: 0.25rem; right: 0.55rem; text-decoration: none; font-weight: bold; color: #900; font-size: 1.1rem; }
.modal-close { display: inline-block; text-decoration: none; font-family: inherit; padding: 0.4rem 1rem;
  border: 2px outset #fff; background: var(--silver); color: #000; cursor: pointer; }
.modal-close:active { border-style: inset; }
.tagline { color: var(--navy); font-weight: bold; }
footer.site { text-align: center; color: #eee; padding: 1rem; font-size: 0.8rem; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid var(--silver); padding: 0.3rem; text-align: left; font-size: 0.85rem; }

/* --- File manager: full-bleed drawer + code editor (/files) --- */

/* Full-bleed: the /files page uses the whole width/height, not the centered 900px card. */
main:has(.files-layout) {
  max-width: none; margin: 0; border: 0; padding: 0.4rem; background: var(--teal);
}

.files-layout {
  display: flex; gap: 0.5rem;
  position: relative;               /* overlay drawer anchors here */
  height: calc(100dvh - 4rem);      /* viewport minus the site header */
}
.files-drawer { flex: 0 0 16rem; margin: 0; padding: 0.5rem; overflow: auto; }
.files-editor { flex: 1 1 auto; min-width: 0; margin: 0; padding: 0.5rem; display: flex; flex-direction: column; }
.files-drawer h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.editor-host { flex: 1 1 auto; min-height: 0; width: 100%; }
.files-editor .cm-editor { height: 100% !important; }   /* CodeMirror fills the available height */
.files-editor .cm-scroller { overflow: auto; }
.editor-msg { margin: 0.3rem 0 0; }

/* Drawer toggle: pure-CSS checkbox whose default meaning flips per breakpoint. */
.drawer-cb { display: none; }
.drawer-toggle {
  cursor: pointer; user-select: none; flex: 0 0 auto;
  padding: 0.15rem 0.55rem; border: 2px outset #fff; background: var(--silver);
  font-weight: bold; line-height: 1.2;
}
.drawer-toggle:active { border-style: inset; }
.editor-hint { color: #333; }

/* WIDE: push mode — drawer open by default; toggle collapses it and the editor fills. */
@media (min-width: 900px) {
  .files-drawer { display: block; position: static; }
  .drawer-cb:checked ~ .files-layout .files-drawer { display: none; }
}
/* NARROW: overlay mode — drawer auto-collapsed; toggling it overlays it above the editor. */
@media (max-width: 899px) {
  .files-drawer { display: none; }
  .drawer-cb:checked ~ .files-layout .files-drawer {
    display: block; position: absolute; top: 2.4rem; left: 0; bottom: 0;
    width: 16rem; max-width: 85%; z-index: 20; background: #fff;
    box-shadow: 4px 4px 8px rgba(0,0,0,0.4);
  }
}

.drawer-toolbar { display: flex; gap: 0.3rem; margin-bottom: 0.5rem; }
.drawer-toolbar button { padding: 0.2rem 0.5rem; font-size: 0.8rem; }
.drawer-inline { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; }
.drawer-inline input { padding: 0.2rem; font-family: 'Courier New', monospace; max-width: none; }
.drawer-inline button { padding: 0.2rem 0.5rem; }

.file-tree { font-family: 'Courier New', monospace; font-size: 0.85rem; }
.tree-row { display: flex; align-items: center; gap: 0.2rem; padding: 0.1rem 0; white-space: nowrap; }
.tree-row.sel { background: var(--navy); }
.tree-row.sel .tree-name { color: #fff; }
.tree-toggle { width: 1rem; text-align: center; cursor: pointer; user-select: none; }
.tree-name { cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.tree-name:hover { text-decoration: underline; }
.tree-folder { font-weight: bold; }
.tree-del { margin-left: auto; padding: 0 0.25rem; border: 1px outset #fff; font-size: 0.75rem; line-height: 1.3; }
.tree-confirm { margin-left: auto; font-size: 0.75rem; display: flex; gap: 0.2rem; align-items: center; }
.tree-confirm button { padding: 0 0.35rem; font-size: 0.75rem; }

.editor-bar {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; flex-wrap: wrap;
  position: relative; z-index: 30; background: var(--silver);   /* stays above the overlay drawer */
}
.editor-bar .editor-file { font-family: 'Courier New', monospace; word-break: break-all; flex: 1 1 auto; }
.editor-actions { display: flex; gap: 0.3rem; margin-left: auto; }
.editor-actions button.on { border-style: inset; }
.rename-input { flex: 1 1 auto; font-family: 'Courier New', monospace; max-width: none; padding: 0.15rem 0.3rem; }

/* Editor / live-preview split */
.editor-split { display: flex; gap: 0.5rem; flex: 1 1 auto; min-height: 0; }
.editor-split .editor-host { flex: 1 1 50%; }
.editor-preview { flex: 1 1 50%; min-width: 0; border: 2px inset var(--silver); background: #fff; }
@media (max-width: 899px) { .editor-split { flex-direction: column; } }
