:root {
  --serif: "iA Writer Quattro S", "Liberation Serif", "Nimbus Roman", Georgia, serif;
  --sans: "iA Writer Duo S", "Noto Sans", "Liberation Sans", sans-serif;
  --mono: "iA Writer Mono S", "Liberation Mono", ui-monospace, monospace;
  --bg: #14120f;
  --bg-2: #1e1b17;
  --line: #3c342c;
  --ink: #f4eee4;
  --muted: #c4b8a6;
  --moss: #9db892;
  --seal: #e4894a;
  --seal-ink: #1c120c;
  --paper: #f7f1e6;
  --paper-ink: #1d1915;
  --paper-muted: #5e564c;
  --paper-line: #e2d8c8;
  --focus: #e7b15a;
  --warn: #e7b15a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 0% -10%, #2c241c 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea, select, summary { font: inherit; color: inherit; }

button, summary { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 8px;
  top: -40px;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 6px 10px;
  border-radius: 8px;
  z-index: 9;
}

.skip:focus { top: 8px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px 20px;
  align-items: end;
  padding: 12px 16px 6px;
}

.brand { display: flex; gap: 10px; align-items: center; }

.eyebrow, .slip-kicker {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.razor-form { min-width: 0; }

.razor-form label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.razor-form textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: 4.8em;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 4px 0 6px;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.35;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

button, .menu summary {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 40px;
}

button.primary {
  background: var(--seal);
  border-color: var(--seal);
  color: var(--seal-ink);
  font-weight: 600;
}

button.primary:hover { filter: brightness(1.05); }

button.armed { border-color: #e07a6a; color: #e07a6a; }

.menu { position: relative; }

.menu summary { list-style: none; }

.menu summary::-webkit-details-marker { display: none; }

.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  padding: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.menu-pop button {
  border-radius: 8px;
  text-align: left;
  width: 100%;
}

.banner, .error {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 16px 6px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.banner { background: #2a231c; }

.error { background: #3a221e; color: #f3c7bc; }

.banner button {
  min-height: 32px;
  flex: 0 0 auto;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0 16px 8px;
}

.checks button {
  min-height: 32px;
  padding: 2px 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.checks button.ok {
  color: var(--moss);
  border-color: #3d5340;
}

.switch {
  display: none;
  gap: 6px;
  padding: 0 12px 10px;
}

.switch button { flex: 1; }

.switch button[aria-selected="true"] {
  background: var(--ink);
  color: var(--seal-ink);
  border-color: var(--ink);
}

.desk {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 336px;
  gap: 12px;
  padding: 0 12px 12px;
}

.library, .slip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.library-head { padding: 10px 10px 0; }

.search input {
  width: 100%;
  background: #14120f;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 1rem;
}

.search input::placeholder,
.razor-form textarea::placeholder,
.controls input::placeholder {
  color: #8d8274;
  opacity: 1;
}

#folders { overflow: auto; padding: 4px 8px 8px; flex: 1; }

.hint {
  margin: 0;
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 0.75rem;
}

.folder {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 8px 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--muted);
  min-height: 32px;
}

.folder.on { color: var(--seal); }

.folder span { letter-spacing: 0; }

.note-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px 6px 10px;
  min-height: 34px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-btn[aria-current="true"] {
  background: #2a241c;
  box-shadow: inset 3px 0 0 var(--seal);
}

.empty-list {
  margin: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.note {
  background: var(--paper);
  color: var(--paper-ink);
  color-scheme: light;
  border-radius: 14px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

.note :focus-visible { outline-color: #9a4e1c; }

.empty {
  margin: auto;
  max-width: 36ch;
  padding: 32px 24px;
}

.empty h2 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.6rem;
  margin: 0 0 8px;
}

.empty p { margin: 0; color: var(--paper-muted); }

#editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 16px 18px 10px;
}

#note-title {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.8rem;
  line-height: 1.15;
  padding: 0 0 8px;
  color: var(--paper-ink);
}

#note-title:focus-visible {
  outline: none;
  box-shadow: inset 0 -2px 0 #9a4e1c;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding-bottom: 8px;
}

.meta label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-muted);
  min-width: 0;
}

.meta label:last-child { flex: 1; }

.meta select, .meta input {
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--paper-ink);
  background: transparent;
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  padding: 6px 8px;
  width: 100%;
  min-width: 0;
}

#note-title::placeholder,
#note-body::placeholder,
.meta input::placeholder {
  color: #b3a894;
  opacity: 1;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 0;
}

.links:empty { display: none; }

.links span {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-muted);
}

.links button {
  min-height: 30px;
  padding: 2px 8px;
  border-color: var(--paper-line);
  color: var(--paper-ink);
  font-size: 0.85rem;
}

.links button.missing { border-style: dashed; }

#note-body {
  flex: 1;
  min-height: 180px;
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--paper-ink);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.55;
  padding: 10px 0;
}

.note-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--paper-muted);
  font-size: 0.85rem;
  padding-top: 4px;
}

.note-foot button {
  color: var(--paper-ink);
  border-color: var(--paper-line);
  min-height: 34px;
}

.slip-kicker { padding: 12px 14px 0; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
}

.tabs button { flex: 1; min-height: 34px; padding: 4px 8px; }

.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: var(--seal-ink);
  border-color: var(--ink);
}

.slip-body {
  overflow: auto;
  padding: 0 14px 12px;
  flex: 1;
  min-height: 0;
}

.slip h3 {
  margin: 10px 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.slip ul { margin: 0; padding-left: 1.1rem; }

.slip li { margin: 0 0 4px; overflow-wrap: break-word; }

.warn, .okline { margin: 0; }

.warn { color: var(--warn); }

.okline { color: var(--moss); }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}

.controls select, .controls input {
  width: 100%;
  background: #100e0c;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 1rem;
  min-width: 0;
}

.prompt {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  background: #100e0c;
  color: var(--ink);
  padding: 10px;
  border-radius: 8px;
  margin: 0;
}

.slip-foot { padding: 0 12px 12px; }

.slip-foot button { width: 100%; }

@media (max-width: 860px) {
  .top { grid-template-columns: 1fr; gap: 10px; }
  .switch { display: flex; }
  .desk { display: block; }
  body { height: auto; min-height: 100%; overflow: auto; }
  .library, .note, .slip { display: none; min-height: 70dvh; }
  .desk[data-panel="library"] .library,
  .desk[data-panel="note"] .note,
  .desk[data-panel="slip"] .slip { display: flex; }
  h1 { font-size: 1.3rem; }
  #note-title { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
