:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #eef2f4;
  --ink: #202428;
  --muted: #66717c;
  --line: #d9dee4;
  --accent: #2f6f5e;
  --accent-strong: #24584b;
  --danger: #a13d3d;
  --danger-bg: #f7e8e8;
  --focus: #c4932f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: var(--accent);
}

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.switcher {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.switcher a {
  min-width: 82px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
}

.switcher a.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(32, 36, 40, 0.08);
}

.content {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.page-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-heading h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
}

.page-heading p {
  margin: 8px 0 0;
  color: var(--muted);
}

.tool-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.note-form,
.task-form,
.filter-form,
.stack-form {
  display: grid;
  gap: 10px;
}

.note-form,
.task-form,
.filter-form,
.login-panel,
.empty-state,
.note-detail,
.note-row,
.task-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.note-form,
.task-form,
.filter-form,
.login-panel,
.empty-state,
.note-detail {
  padding: 18px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

input {
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  min-height: 140px;
  resize: vertical;
  padding: 10px;
}

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 32%, transparent);
  outline-offset: 2px;
}

button,
.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

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

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

.secondary-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  border-color: color-mix(in srgb, var(--danger) 26%, transparent);
  background: var(--danger-bg);
  color: var(--danger);
}

.checkbox-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-button {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.text-link {
  align-self: center;
  font-weight: 700;
  text-decoration: none;
}

.alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 650;
}

.alert.success {
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  background: #e8f2ef;
  color: var(--accent-strong);
}

.alert.error {
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
  background: var(--danger-bg);
  color: var(--danger);
}

.notes-list ol,
.task-list ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
}

.note-summary {
  min-width: 0;
}

.note-id {
  font-weight: 800;
  text-decoration: none;
}

.note-summary time {
  margin-left: 10px;
  color: var(--muted);
  font-size: 14px;
}

.note-summary p {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.task-panel {
  margin-bottom: 20px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.task-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

.task-complete-form {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
}

.task-complete-form input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.task-summary {
  min-width: 0;
}

.task-summary p {
  margin: 0 0 6px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.task-summary time {
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 20px;
}

.empty-state p {
  margin: 0;
}

.note-detail pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, ui-monospace, monospace;
  line-height: 1.55;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
}

.login-panel h1 {
  margin: 0 0 18px;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .switcher {
    width: 100%;
  }

  .tool-panel,
  .note-row,
  .task-row,
  .page-heading {
    grid-template-columns: 1fr;
  }

  .page-heading,
  .note-row,
  .task-row,
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .note-row form,
  .note-row button,
  .task-row form,
  .task-row button,
  .inline-form button {
    width: 100%;
  }
}
