html,
body {
  height: 100%;
}

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --sidebar: #eee7dc;
  --line: #d8cfc1;
  --text: #2d2924;
  --muted: #746b60;
  --accent: #b77a1e;
  --accent-strong: #8f5a11;
  --danger: #b83a2d;
  --shadow: 0 18px 60px rgba(65, 48, 24, 0.16);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #faf8f1 0%, #eee6d8 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100%;
  overflow: hidden;
}

.auth-view {
  display: grid;
  height: 100%;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(183, 122, 30, 0.16);
}

.auth-form input {
  height: 44px;
  padding: 0 12px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.icon-text-button,
.icon-button,
.danger-button,
.toolbar button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.icon-text-button,
.icon-button,
.toolbar button {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover,
.icon-text-button:hover,
.icon-button:hover,
.toolbar button:hover {
  background: #fff;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  min-height: 38px;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.primary-icon-button {
  background: var(--accent);
  color: white;
}

.primary-icon-button:hover {
  background: var(--accent-strong);
}

.danger-button {
  background: transparent;
  border-color: rgba(184, 58, 45, 0.28);
  color: var(--danger);
  padding: 0 12px;
}

.notes-view {
  display: grid;
  grid-template-columns: minmax(170px, 20vw) 1fr;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(238, 231, 220, 0.94);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
}

.sidebar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 18px 14px;
}

.sidebar-actions .icon-button {
  flex: 0 0 auto;
}

.notes-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 10px 18px;
}

.group-item {
  margin-bottom: 8px;
}

.group-header {
  display: grid;
  align-items: center;
  grid-template-columns: 28px 1fr auto 28px;
  gap: 4px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
}

.group-header:hover {
  background: rgba(255, 255, 255, 0.46);
}

.group-toggle,
.group-name {
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.group-toggle {
  width: 26px;
  height: 30px;
  padding: 0;
  font-size: 15px;
}

.group-name {
  overflow: hidden;
  padding: 0;
  font-size: 13px;
  font-weight: 780;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  min-width: 22px;
  color: #9b8e7c;
  font-size: 12px;
  text-align: right;
}

.group-add-note {
  display: inline-grid;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: #8d7d68;
}

.group-add-note svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.group-add-note:hover {
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.6);
}

.group-notes {
  min-height: 14px;
  padding: 3px 0 0 20px;
}

.group-empty {
  margin: 4px 0 7px;
  padding: 10px 12px;
  border: 1px dashed rgba(151, 135, 113, 0.45);
  border-radius: 8px;
  color: #9b8e7c;
  font-size: 13px;
}

.note-item {
  width: 100%;
  min-height: 76px;
  margin-bottom: 7px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.dragging {
  opacity: 0.44;
}

.note-item:hover {
  background: rgba(255, 255, 255, 0.58);
}

.note-item.active {
  background: #fff6df;
  border-color: #e2c175;
}

.note-title {
  display: block;
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-preview {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-date {
  display: block;
  margin-top: 8px;
  color: #9b8e7c;
  font-size: 12px;
}

.editor-pane {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto 1fr;
  background: var(--panel);
}

.editor-header {
  display: grid;
  gap: 10px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid rgba(216, 207, 193, 0.65);
}

.editor-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.group-select-label {
  display: grid;
  width: min(240px, 100%);
  grid-template-columns: auto minmax(130px, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.group-select-label select {
  height: 34px;
  padding: 0 10px;
  background: #fff;
}

.title-input {
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 30px;
  font-weight: 760;
  letter-spacing: 0;
}

.title-input:focus {
  box-shadow: none;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(216, 207, 193, 0.65);
  background: rgba(255, 251, 242, 0.86);
}

.toolbar button {
  min-width: 38px;
  padding: 0 11px;
}

.underline {
  text-decoration: underline;
}

.editor {
  min-height: 0;
  overflow: auto;
  padding: 28px 24px 60px;
  outline: none;
  color: #2b2722;
  font-size: 17px;
  line-height: 1.62;
}

.editor:empty::before {
  color: #aa9e8f;
  content: "写点什么...";
}

.editor img {
  display: block;
  max-width: min(720px, 100%);
  height: auto;
  margin: 14px 0;
  border-radius: 8px;
}

.editor p {
  margin: 0 0 0.8em;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-state p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .notes-view {
    grid-template-columns: 1fr;
    grid-template-rows: 38vh 62vh;
  }

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

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

  .editor-header,
  .toolbar,
  .editor {
    padding-left: 16px;
    padding-right: 16px;
  }
}
