:root {
  --desk: #e7e0d3;
  --ink: #241f1a;
  --muted: #6f675d;
  --paper: #fbf7ef;
  --line: #e4d9c6;
  --sidebar: #1c2822;
  --sidebar-text: #f6f1e7;
  --sidebar-dim: #b7c0b8;
  --brass: #c6964a;
  --danger: #8d3d36;
  --ok: #2f6b4f;
  --shadow: 0 18px 50px rgba(48, 36, 18, 0.12);
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--desk);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(198, 150, 74, 0.18), transparent 28rem),
    var(--desk);
}

.card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}

.mark {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--brass);
  font-weight: 700;
}

.card h1 { margin: 8px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 40px; font-weight: 500; }

.lede, .hint { color: var(--muted); line-height: 1.45; }

.tabs { display: flex; gap: 8px; margin: 18px 0; }

.tab, .rail button, .editor-bar button, .share button, .card button[type="submit"] {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
}

.tab.is-on, .card button[type="submit"], #new-note {
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-color: var(--sidebar);
}

.card label, .share label { display: grid; gap: 6px; margin-bottom: 12px; font-size: 14px; }

.card input, .share input, .share select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
}

.form-error { min-height: 1.2em; margin: 0 0 8px; color: var(--danger); }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.shell.share-open { grid-template-columns: 280px minmax(0, 1fr) 320px; }

.rail {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 22px 16px 16px;
}

.rail-top { display: grid; gap: 14px; }

#new-note { width: 100%; border-radius: 12px; padding: 12px 14px; background: var(--brass); color: #24180a; border: 0; font-weight: 650; }

.note-list { list-style: none; margin: 18px 0; padding: 0; overflow: auto; flex: 1; }

.note-list button {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  padding: 10px 12px;
}

.note-list button.is-on { background: rgba(255, 255, 255, 0.08); }

.note-list strong, .note-list span { display: block; }

.note-list strong { font-weight: 600; }

.note-list span, .rail-foot { color: var(--sidebar-dim); font-size: 13px; }

.rail-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

#who { color: var(--sidebar-text); }

.rail-foot button { color: var(--sidebar-text); border-color: rgba(255, 255, 255, 0.16); }

.sheet { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.blank, .editor { margin: 28px auto; width: min(820px, calc(100% - 32px)); }

.blank {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.blank h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 36px; margin: 0 0 8px; }

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 56px);
}

.editor-bar, .share-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }

.status { margin: 0; flex: 1; color: var(--muted); font-size: 14px; }

.status.is-warn { color: var(--danger); }

.title, .body {
  border: 0;
  background: transparent;
  width: 100%;
  padding: 8px 22px;
}

.title { font-family: Georgia, "Times New Roman", serif; font-size: 34px; margin-top: 12px; }

.body { flex: 1; resize: none; min-height: 320px; line-height: 1.6; font-size: 18px; padding-bottom: 20px; }

.presence { margin: 0; padding: 0 22px 16px; color: var(--muted); font-size: 14px; min-height: 1.2em; }

.share {
  background: var(--paper);
  border-left: 1px solid var(--line);
  min-height: 100vh;
  padding: 8px 16px 20px;
  display: flex;
  flex-direction: column;
}

.share-head h2 { flex: 1; font-size: 18px; margin: 0; }

.share-head button { border: 0; background: transparent; font-size: 28px; line-height: 1; }

.members { list-style: none; margin: 0 0 16px; padding: 0; }

.members li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

.members button, .results button { border: 0; background: transparent; color: var(--danger); padding: 4px 0; }

.results { list-style: none; margin: -6px 0 12px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

.results button { display: block; width: 100%; text-align: left; padding: 8px 12px; color: var(--ink); background: #fff; }

.results button:hover { background: #f3ecdf; }

.danger { margin-top: auto; color: var(--danger); border-color: #e3c6c2; }

@media (max-width: 860px) {
  .shell, .shell.share-open { grid-template-columns: 1fr; }
  .rail, .share, .sheet { min-height: 100vh; }
  .shell.note-open .rail, .shell.share-open .sheet, .shell.share-open .rail { display: none; }
  .shell:not(.note-open) .sheet { display: none; }
  .blank, .editor { width: auto; margin: 0; border-radius: 0; min-height: 100vh; box-shadow: none; }
  .back { display: inline-flex; }
}

@media (min-width: 861px) {
  .back { display: none; }
}
