:root {
  --outer: #e8e7e2;
  --paper: #f3f2ed;
  --surface: #fbfaf6;
  --surface-strong: #ffffff;
  --ink: #252824;
  --muted: #767b72;
  --line: rgba(37, 40, 36, 0.11);
  --accent: #687b6b;
  --accent-soft: #dce3da;
  --danger: #a35d55;
  --shadow: rgba(36, 42, 36, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--outer);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
}

body {
  min-height: 100vh;
  padding: clamp(8px, 2vw, 24px);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  width: min(1480px, 100%);
  min-height: calc(100vh - clamp(16px, 4vw, 48px));
  margin: 0 auto;
  overflow: hidden;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--line);
  border-radius: clamp(18px, 2.5vw, 30px);
  background: var(--paper);
  box-shadow: 0 24px 70px var(--shadow);
}

.topbar {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(20px, 3.8vw, 52px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-family: "Songti SC", STSong, Georgia, serif;
}

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

.brand strong {
  font-size: 14px;
  font-weight: 680;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-name {
  color: var(--muted);
  font-size: 12px;
}

.text-button,
.icon-button,
.primary-button,
.danger-button {
  border: 0;
  cursor: pointer;
}

.text-button {
  padding: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.text-button:hover {
  color: var(--ink);
}

.login-view {
  display: grid;
  min-height: 620px;
  place-items: center;
  padding: 42px 20px 80px;
}

.login-card {
  width: min(420px, 100%);
  padding: clamp(30px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(36, 42, 36, 0.06);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.login-card h1,
.sidebar-heading h1 {
  margin: 0;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.login-card h1 {
  font-size: clamp(30px, 7vw, 40px);
}

.login-copy {
  margin: 14px 0 30px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.login-card form,
.login-card label {
  display: grid;
}

.login-card form {
  gap: 18px;
}

.login-card label {
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.login-card input,
.search-field,
.tags-field input {
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.login-card input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--ink);
}

.form-error {
  min-height: 18px;
  margin: -6px 0 -4px;
  color: var(--danger);
  font-size: 12px;
}

.primary-button,
.danger-button {
  min-height: 40px;
  padding: 0 17px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 680;
}

.primary-button {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 20px rgba(74, 94, 77, 0.16);
}

.primary-button:hover {
  background: #5a6f5e;
}

.danger-button {
  background: transparent;
  color: var(--danger);
}

.danger-button:hover {
  background: rgba(163, 93, 85, 0.08);
}

.login-button {
  width: 100%;
  margin-top: 2px;
}

.notes-view {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(270px, 330px) 1fr;
}

.notes-sidebar {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto 1fr;
  padding: 34px 22px 24px;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.56);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.sidebar-heading h1 {
  font-size: 27px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.search-field {
  display: flex;
  height: 42px;
  align-items: center;
  gap: 8px;
  margin: 24px 0 14px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--muted);
}

.search-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.notes-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 3px;
}

.note-list-item {
  display: grid;
  width: 100%;
  gap: 7px;
  margin-bottom: 7px;
  padding: 15px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

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

.note-list-item.is-active {
  border-color: var(--line);
  background: var(--surface-strong);
  box-shadow: 0 10px 24px rgba(36, 42, 36, 0.05);
}

.note-list-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-list-preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #92968f;
  font-size: 9px;
}

.notes-list-message {
  padding: 32px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.editor {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.empty-state {
  display: grid;
  width: min(430px, calc(100% - 40px));
  min-height: 100%;
  margin: 0 auto;
  place-content: center;
  justify-items: center;
  padding: 70px 0 110px;
  text-align: center;
}

.empty-mark {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--accent);
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 24px;
}

.empty-state h2 {
  margin: 0;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 30px;
  font-weight: 500;
}

.empty-state p {
  margin: 14px 0 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.editor-form {
  display: grid;
  min-height: 100%;
  grid-template-rows: auto auto auto minmax(360px, 1fr);
  padding: 28px clamp(28px, 6vw, 86px) 44px;
}

.editor-toolbar {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.save-status {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
}

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

.title-input,
.content-input,
.tags-field input {
  border: 0;
  outline: 0;
  color: var(--ink);
}

.title-input {
  width: 100%;
  margin: 40px 0 24px;
  background: transparent;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 500;
  letter-spacing: -0.045em;
}

.title-input::placeholder,
.content-input::placeholder,
.tags-field input::placeholder {
  color: #a9ada6;
}

.tags-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.tags-field input {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 11px;
}

.content-input {
  width: 100%;
  min-height: 360px;
  resize: none;
  background: transparent;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.9;
}

.mobile-editor-bar {
  display: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(360px, calc(100% - 32px));
  padding: 12px 16px;
  transform: translateY(20px);
  border-radius: 12px;
  background: var(--ink);
  box-shadow: 0 14px 30px rgba(20, 24, 20, 0.18);
  color: white;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  body {
    padding: 0;
  }

  .app-shell {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    min-height: 68px;
    padding: 12px 18px;
  }

  .notes-view {
    display: block;
    position: relative;
  }

  .notes-sidebar,
  .editor {
    position: absolute;
    inset: 0;
    min-height: calc(100vh - 68px);
  }

  .notes-sidebar {
    border-right: 0;
    padding: 28px 16px 20px;
  }

  .editor {
    display: none;
    z-index: 2;
  }

  .notes-view.is-editing .editor {
    display: block;
  }

  .notes-view.is-editing .notes-sidebar {
    display: none;
  }

  .mobile-editor-bar {
    display: flex;
    height: 50px;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
  }

  .editor-form {
    min-height: calc(100vh - 118px);
    grid-template-rows: auto auto auto minmax(360px, 1fr);
    padding: 16px 20px 34px;
  }

  .editor-toolbar {
    align-items: flex-end;
  }

  .save-status {
    display: none;
  }

  .title-input {
    margin-top: 26px;
    font-size: 36px;
  }

  .empty-state {
    min-height: calc(100vh - 118px);
  }

  .login-view {
    min-height: calc(100vh - 68px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
