:root {
  --bg: #0f1220;
  --panel: #171a2a;
  --muted: #9aa3b2;
  --text: #e6e9ef;
  --primary: #4f8cff;
  --danger: #ff5a5f;
  --border: #2a2f45;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Noto Sans, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 18, 32, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-title {
  margin: 0;
  font-size: 18px;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.app-main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px;
}

.saved-section, .editor-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 0 12px;
}
.section-title {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.docs-list {
  list-style: none;
  margin: 8px 0 0 0;
  padding: 0;
  max-height: calc(100vh - 200px);
  overflow: auto;
}
.docs-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.docs-list li:hover { background: rgba(255,255,255,0.03); }
.doc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { color: var(--muted); font-size: 12px; }

.editor-section {
  display: flex;
  flex-direction: column;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.current-doc { color: var(--muted); font-size: 14px; }
.toolbar-actions { display: flex; gap: 8px; }
.search { display: inline-flex; gap: 6px; align-items: center; }
.search input {
  width: 200px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

.editor {
  width: 100%;
  height: calc(100vh - 220px);
  padding: 14px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  resize: none;
}
.editor:disabled { opacity: 0.6; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: rgba(255,255,255,0.07); }
.btn.primary { border-color: transparent; background: var(--primary); color: #0b1021; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { border-color: #6a2431; background: #ab2f43; color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.modal { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,0.4); }
.modal-form { padding: 16px; min-width: 320px; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field span { color: var(--muted); font-size: 12px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.muted { color: var(--muted); font-size: 12px; }
.error { color: #ff8b8f; font-size: 12px; margin-top: 6px; }

.app-footer { padding: 12px 16px; color: var(--muted); }

@media (max-width: 900px) {
  .app-main { grid-template-columns: 1fr; }
  .editor { height: 50vh; }
}
