:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #d6dde8;
  --accent: #166534;
  --accent-strong: #14532d;
  --focus: #2563eb;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover,
select:hover,
input[type="color"]:hover {
  border-color: #94a3b8;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.editor:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.new-doc {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.new-doc:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.doc-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 8px 10px 12px;
  background: transparent;
  text-align: left;
}

.doc-open {
  display: block;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.doc-open:hover {
  border-color: transparent;
}

.doc-item.active {
  border-color: #99f6e4;
  background: #ccfbf1;
}

.doc-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.doc-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.delete-doc {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 7px;
  color: #b91c1c;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
}

.topbar,
.toolbar,
.statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
}

.topbar {
  justify-content: space-between;
}

.title-input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
}

.top-actions,
.toolbar {
  flex-wrap: wrap;
}

.toolbar select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 0 10px;
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

input[type="color"] {
  width: 42px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.paper-wrap {
  overflow: auto;
  padding: 32px;
}

.editor {
  width: min(900px, 100%);
  min-height: calc(100vh - 238px);
  margin: 0 auto;
  padding: 54px 62px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  line-height: 1.72;
  font-size: 17px;
}

.editor:empty::before {
  content: "开始输入正文...";
  color: #94a3b8;
}

.editor h1,
.editor h2,
.editor h3 {
  line-height: 1.25;
}

.editor blockquote {
  margin: 18px 0;
  padding-left: 18px;
  border-left: 4px solid #0f766e;
  color: #475569;
}

.editor pre {
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
}

.statusbar {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-input {
    font-size: 24px;
  }

  .paper-wrap {
    padding: 16px;
  }

  .editor {
    min-height: 58vh;
    padding: 30px 22px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .toolbar,
  .statusbar {
    display: none;
  }

  .app-shell,
  .workspace {
    display: block;
  }

  .paper-wrap {
    padding: 0;
    overflow: visible;
  }

  .editor {
    width: 100%;
    min-height: 0;
    padding: 0;
    box-shadow: none;
  }
}
