:root {
  --bg: #f2f2f7;
  --panel: #f7f7fb;
  --surface: #ffffff;
  --surface-alt: #ededf3;
  --border: #d9d9df;
  --separator: #e6e6eb;
  --text: #111111;
  --muted: #6e6e73;
  --muted-soft: #9d9da3;
  --accent: #f2b300;
  --accent-soft: #fff4cc;
  --danger: #ff3b30;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow: 0 16px 40px rgba(17, 17, 17, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f5f5f8 0%, #ececf1 100%);
}

body {
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.app-shell {
  max-width: 1540px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-columns: 290px 390px minmax(440px, 1fr);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(17, 17, 17, 0.04);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar,
.notes-panel,
.editor-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 36px);
}

.sidebar {
  background: #efeff4;
}

.notes-panel {
  background: #f4f4f8;
}

.editor-panel {
  background: #ffffff;
}

.ios-topbar {
  min-height: 58px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--separator);
  background: rgba(247, 247, 251, 0.94);
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.ghost-button {
  padding: 6px 0;
  background: transparent;
  color: var(--accent);
  font-size: 1.02rem;
}

.ghost-button.accent {
  font-weight: 600;
}

.brand,
.stats-grid,
.smart-nav,
.folders,
.search-shell,
.notes-toolbar,
.notes-list,
.empty-state,
.editor {
  padding-left: 18px;
  padding-right: 18px;
}

.brand {
  padding-top: 18px;
  padding-bottom: 12px;
}

.brand h1,
.notes-toolbar h2,
.empty-state h2 {
  margin: 0;
  font-size: 2.75rem;
  line-height: 1;
  letter-spacing: -0.05em;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subtle-copy,
.muted,
.note-card-preview,
.note-card-folder,
.note-card-date,
.meta-row,
.stat-label {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-bottom: 16px;
}

.stat-card {
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.84);
  border-radius: var(--radius-md);
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
}

.smart-nav,
.folder-list,
.notes-list,
.checklist-items {
  display: flex;
  flex-direction: column;
}

.smart-nav {
  padding-bottom: 10px;
}

.nav-item,
.folder-item {
  min-height: 52px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  color: var(--text);
  border-bottom: 1px solid var(--separator);
}

.nav-item.is-active,
.folder-item.is-active {
  color: var(--accent);
}

.nav-item strong,
.folder-item strong {
  color: var(--muted);
  font-weight: 500;
}

.folders {
  padding-top: 14px;
  padding-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.folder-create,
.share-row {
  display: flex;
  gap: 10px;
}

.folder-create {
  margin-bottom: 8px;
}

.search-shell {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  padding-bottom: 10px;
}

.search-input,
.folder-create input,
.field select,
.share-row input,
.checklist-text {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: 14px;
  outline: none;
  color: var(--text);
}

.note-title-input,
.note-body-input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

.search-input:focus,
.folder-create input:focus,
.field select:focus,
.share-row input:focus,
.checklist-text:focus {
  border-color: rgba(242, 179, 0, 0.55);
  background: #ffffff;
}

.search-action,
.button,
.icon-button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}

.button.secondary,
.search-action {
  background: var(--surface-alt);
}

.button.primary {
  background: var(--accent);
  color: #111111;
  font-weight: 600;
}

.button.danger-fill {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
  font-weight: 600;
}

.notes-toolbar {
  padding-top: 8px;
  padding-bottom: 14px;
}

.selection-bar {
  margin: 0 18px 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--separator);
  border-radius: 18px;
}

.selection-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--muted);
}

.selection-meta strong {
  color: var(--text);
  font-size: 1.1rem;
}

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

.selection-actions select {
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--surface-alt);
}

.selection-actions select:focus {
  outline: none;
  border-color: rgba(242, 179, 0, 0.55);
  background: #ffffff;
}

.notes-toolbar h2 {
  font-size: 2.55rem;
}

.subtle-copy {
  margin: 8px 0 0;
  font-size: 0.94rem;
}

.notes-list {
  padding-bottom: 18px;
  gap: 8px;
  overflow: auto;
}

.note-card {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.note-card:hover {
  transform: translateY(-1px);
}

.note-card.is-active {
  border-color: rgba(242, 179, 0, 0.6);
  box-shadow: 0 10px 24px rgba(242, 179, 0, 0.12);
}

.note-card.is-selection {
  user-select: none;
}

.note-card.is-selected {
  border-color: rgba(242, 179, 0, 0.7);
  background: #fffdf5;
  box-shadow: 0 8px 20px rgba(242, 179, 0, 0.12);
}

.note-card-top,
.note-card-bottom,
.editor-header,
.editor-meta-grid,
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.note-card-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.note-card-affordances {
  display: flex;
  align-items: center;
  gap: 10px;
}

.note-card-selector {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1.5px solid #c9c9cf;
  background: #ffffff;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 120ms ease, transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.note-card-selector.is-visible {
  opacity: 1;
  transform: scale(1);
}

.note-card-selector.is-selected {
  border-color: var(--accent);
  background: radial-gradient(circle at center, var(--accent) 0 52%, transparent 56%);
}

.note-card-badge {
  align-self: flex-start;
  min-width: 12px;
  min-height: 12px;
  border-radius: 999px;
  background: transparent;
}

.note-card-badge.is-marked {
  background: var(--accent);
}

.note-card-preview {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-bottom {
  font-size: 0.88rem;
}

.editor {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.editor-nav {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.96);
}

.editor-header {
  padding-top: 20px;
  padding-bottom: 14px;
  align-items: flex-start;
}

.editor-title-wrap {
  flex: 1;
  min-width: 0;
}

.note-title-input {
  margin: 0;
  font-size: 2.7rem;
  line-height: 1.05;
  letter-spacing: -0.055em;
  font-weight: 700;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-button {
  min-height: 36px;
  padding: 8px 12px;
  background: var(--surface-alt);
  color: var(--muted);
}

.icon-button.is-active {
  background: var(--accent-soft);
  color: #946700;
}

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

.meta-row {
  margin-top: 8px;
  font-size: 0.9rem;
}

.editor-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 4px;
  padding-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.note-body-input {
  flex: 1;
  min-height: 320px;
  resize: none;
  font-size: 1.08rem;
  line-height: 1.7;
  padding: 6px 0 0;
}

.checklist-section,
.share-panel {
  margin-top: 18px;
  padding: 18px;
  background: #fafafc;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
}

.checklist-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.checkbox-wrap {
  position: relative;
  width: 22px;
  height: 22px;
}

.checkbox-wrap input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.checkbox-custom {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1.5px solid #c9c9cf;
  background: #fff;
}

.checkbox-wrap input:checked + .checkbox-custom {
  border-color: var(--accent);
  background: radial-gradient(circle at center, var(--accent) 0 48%, transparent 52%);
}

.empty-state,
.empty-list {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  padding-top: 40px;
  padding-bottom: 40px;
}

.empty-state p,
.empty-list p {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.editor-footer {
  margin-top: auto;
  padding: 18px 0 22px;
}

.editor-toolbar-pill {
  min-height: 54px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  border-radius: 999px;
  background: #f2f2f7;
  color: var(--muted);
  font-size: 0.95rem;
}

.shared-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.shared-shell {
  width: min(760px, 100%);
  padding: 30px;
  background: #ffffff;
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.shared-shell h1 {
  margin: 0;
  font-size: 2.6rem;
  letter-spacing: -0.05em;
}

.shared-content {
  margin-top: 16px;
  white-space: pre-wrap;
  line-height: 1.7;
  color: #1c1c1e;
}

.shared-checklist {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.shared-checklist-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: #f7f7fb;
}

.shared-checklist-item.is-done {
  opacity: 0.72;
}

.is-hidden {
  display: none !important;
}

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

  .brand h1,
  .notes-toolbar h2,
  .empty-state h2,
  .note-title-input {
    font-size: 2.2rem;
  }
}

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

  .sidebar,
  .notes-panel,
  .editor-panel {
    min-height: auto;
  }

  .editor-meta-grid {
    grid-template-columns: 1fr;
  }

  .editor-header,
  .meta-row {
    flex-direction: column;
  }

  .editor-actions {
    justify-content: flex-start;
  }

  .selection-bar,
  .selection-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0;
    gap: 0;
  }

  .panel {
    border-radius: 0;
    box-shadow: none;
    border-left: 0;
    border-right: 0;
  }

  .sidebar {
    display: none;
  }

  .notes-panel {
    min-height: 42vh;
  }

  .notes-toolbar h2,
  .note-title-input,
  .empty-state h2 {
    font-size: 2rem;
  }

  .search-shell,
  .folder-create,
  .share-row,
  .selection-actions {
    flex-direction: column;
  }

  .editor-toolbar-pill {
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    font-size: 0.88rem;
  }
}
