:root {
  color-scheme: dark;
  --page: #000;
  --panel: #171717;
  --border: #2b2b2b;
  --text: #eee;
  --muted: #858585;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--page); }
body {
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, textarea { font: inherit; }
.app-shell { width: 100%; min-height: 100dvh; padding: clamp(6px, 1.2vw, 14px); }
.notepad {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  min-height: calc(100dvh - clamp(12px, 2.4vw, 28px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.toolbar {
  display: flex;
  min-height: 37px;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding: 4px 6px 3px 10px;
  border-bottom: 1px solid var(--border);
}
.save-area {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  margin-right: auto;
}
.save-status {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .02em;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}
.save-action {
  flex: none;
  padding: 2px 0;
  border: 0;
  color: #999;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}
.save-action:hover { color: #d0d0d0; }
.shortcut-hint { margin-left: 4px; color: #626262; font-size: 10px; }
.toolbar-actions { display: flex; flex: none; align-items: center; gap: 4px; }
.utility-button {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border: 1px solid #303030;
  border-radius: 6px;
  color: #a8a8a8;
  background: #1d1d1d;
  font-size: 11px;
  cursor: pointer;
}
.utility-button:hover { border-color: #414141; color: #dcdcdc; background: #272727; }
.language-button {
  min-width: 26px;
  padding-inline: 5px;
  border-color: transparent;
  color: #777;
  background: transparent;
}
.language-button:hover { border-color: #333; color: #bdbdbd; background: #202020; }
.utility-button:active { transform: translateY(1px); }
.utility-button:focus-visible, .save-action:focus-visible { outline: 2px solid #8b8b8b; outline-offset: 2px; }
.utility-button svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.editor {
  width: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: 0;
  padding: clamp(14px, 2.2vw, 26px);
  color: var(--text);
  caret-color: #fff;
  background: var(--panel);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.7;
  tab-size: 2;
}
.editor::placeholder { color: #555; }
::selection { color: #fff; background: #454545; }
@media (max-width: 420px) {
  .app-shell { padding: 5px; }
  .notepad { min-height: calc(100dvh - 10px); border-radius: 8px; }
  .toolbar { min-height: 37px; gap: 4px; padding-left: 8px; }
  .save-area { gap: 5px; }
  .save-action { font-size: 10px; }
  .shortcut-hint { display: none; }
  .utility-button { padding: 0 6px; }
  .editor { padding: 13px; }
}

/* Full-window editor; note management stays in a closed right drawer. */
html, body { height: 100%; background: var(--panel); }
.app-shell { height: 100dvh; min-height: 0; padding: 0; }
.notepad { height: 100%; min-height: 0; border: 0; border-radius: 0; grid-template-rows: auto minmax(0,1fr); }
.toolbar { padding: 5px 10px; }
.toolbar { --toolbar-muted: #626262; }
.save-status, .save-action, .shortcut-hint { color: var(--toolbar-muted); }
.toolbar .utility-button:not(.language-button) { color: var(--toolbar-muted); border-radius: 6px; }
.toolbar .utility-button:not(.language-button):hover, .save-action:hover { color: #999; }
.editor { height: 100%; }
#library { display: none; position: fixed; z-index: 5; inset: 0 0 0 auto; width: min(320px,100%); min-height: 0; flex-direction: column; border-left: 1px solid var(--border); background: #141414; padding: 18px 12px 12px; box-shadow: -12px 0 40px #0006; }
.library-open #library { display: flex; }
.library-top { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 18px; color: #bfbfbf; font-size: 13px; }
#library-close { border: 0; background: transparent; color: #999; font-size: 22px; cursor: pointer; padding: 0 4px; }
#note-search { width: 100%; min-width: 0; border: 1px solid #303030; border-radius: 0; background: #1b1b1b; padding: 9px 10px; color: #eee; font: inherit; font-size: 12px; }
#notes-list { overflow: auto; flex: 1; padding-top: 12px; }
.note-row { display: block; text-align: left; width: 100%; border: 0; border-left: 2px solid transparent; background: transparent; color: #999; padding: 13px 10px; cursor: pointer; }
.note-row:hover { background: #1c1c1c; }
.note-row[aria-current="true"] { border-left-color: #aaa; background: #242424; }
.note-row strong,.note-row span,.note-row small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.note-row strong { color: #d5d5d5; font-size: 13px; font-weight: 500; }
.note-row span { margin: 7px 0; font-size: 11px; }
.note-row small { color: #666; font-size: 10px; }
#library-caption { color: #666; font-size: 10px; line-height: 1.7; padding: 0 10px; }
.document-header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 10px; border-top: 1px solid var(--border); }
#note-title { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; color: #aaa; }
.document-actions { display: flex; gap: 16px; }
.document-header button { border: 0; color: #888; background: transparent; cursor: pointer; padding: 4px 0; font-size: 11px; }
.document-header button:hover { color: #eee; }
button:focus-visible, input:focus-visible { outline: 1px solid #aaa; outline-offset: -2px; }
@media (max-width: 420px) {
 .app-shell { padding: 0; }
 .notepad { min-height: 0; border-radius: 0; }
 .toolbar { flex-wrap: wrap; padding: 5px 8px; }
 .save-area { flex: 1 1 140px; }
}
