:root {
  color-scheme: light;
  --paper: #fffdf6;
  --sidebar: #f5f1e9;
  --sidebar-border: #ddd6c7;
  --ink: #1d1d1f;
  --muted: #73706a;
  --accent: #f5c84c;
  --accent-strong: #d6a400;
  --danger: #c83e32;
  --row-active: #fff8d6;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}

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

.sidebar-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.sidebar-header span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #2d2500;
  font-size: 25px;
  line-height: 30px;
  cursor: pointer;
}

.search-row {
  padding: 0 14px 12px;
}

.search-row input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #ded6c5;
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.75);
}

.search-row input:focus,
.title-input:focus,
.note-body:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(245, 200, 76, 0.18);
}

.notes-list {
  overflow: auto;
  padding: 0 10px 16px;
}

.note-row {
  display: grid;
  width: 100%;
  gap: 6px;
  margin: 0;
  padding: 12px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.note-row:hover {
  background: rgba(255, 255, 255, 0.62);
}

.note-row.active {
  background: var(--row-active);
}

.row-title,
.row-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-title {
  font-weight: 700;
}

.row-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.row-preview {
  color: #5f5a50;
  font-size: 13px;
}

.editor-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  background: var(--paper);
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.title-input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  outline: none;
  padding: 8px 10px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolbar-actions form {
  margin: 0;
}

.save-state {
  min-width: 62px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.toolbar-button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid #d9d2c3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
}

.toolbar-button:hover {
  background: #fff;
}

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

.note-body {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  border-radius: 0;
  outline: none;
  padding: 28px 34px;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.62;
  white-space: pre;
  tab-size: 2;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f7f0dc 0%, #fffdf6 58%, #f0f4f8 100%);
}

.login-panel {
  width: min(100%, 360px);
  padding: 30px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.login-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe783, #f3bf2f);
  color: #3a2d00;
  font-size: 31px;
  font-weight: 800;
}

.login-panel h1 {
  margin: 18px 0 18px;
  font-size: 30px;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  height: 42px;
  width: 100%;
  border: 1px solid #d9d2c3;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.login-form button {
  height: 42px;
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #2d2500;
  font-weight: 700;
  cursor: pointer;
}

.error {
  margin: -6px 0 14px;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 260px minmax(0, 1fr);
    height: 100vh;
  }

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

  .sidebar-header {
    padding-top: 16px;
  }

  .sidebar-header h1 {
    font-size: 25px;
  }

  .editor-toolbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 14px;
  }

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

  .save-state {
    text-align: left;
  }

  .note-body {
    padding: 18px;
    font-size: 14px;
  }
}
