:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-muted: #f8f9fa;
  --text: #222426;
  --muted: #6b6f76;
  --line: #e1e4e8;
  --accent: #2f6f64;
  --accent-strong: #24584f;
  --accent-soft: #e1eee9;
  --warn: #b7472a;
  --warn-soft: #f6e4dd;
  --shadow: none;
  --tag-column-width: 260px;
  --note-column-width: 360px;
  --resizer-width: 5px;
  font-family:
    Aptos, "Aptos Display", Calibri, "Segoe UI", ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.auth-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  overflow: auto;
  padding: 28px clamp(18px, 5vw, 56px);
}

.auth-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, 1120px);
  margin: 0 auto;
}

.auth-logo {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.ghost-button,
.small-primary-button {
  min-height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  padding: 0 14px;
}

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

.ghost-button:hover {
  background: var(--panel-muted);
  color: var(--text);
}

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

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

.auth-layout {
  display: grid;
  width: min(100%, 1120px);
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  align-items: center;
  gap: clamp(32px, 8vw, 96px);
  margin: 0 auto;
  padding: 56px 0 68px;
}

.auth-copy {
  max-width: 680px;
}

.brand-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  margin: 0 0 20px;
  padding: 0 12px;
}

.auth-copy h1 {
  max-width: 680px;
  margin: 0;
  color: var(--text);
  font-size: clamp(44px, 7vw, 76px);
  font-weight: 650;
  line-height: 0.98;
  letter-spacing: 0;
}

.auth-lede {
  max-width: 520px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.auth-points span {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 12px;
}

.auth-card {
  width: min(100%, 400px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
}

.auth-heading {
  margin-bottom: 18px;
}

.auth-heading h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border-radius: 8px;
  background: var(--panel-muted);
  margin-bottom: 18px;
  padding: 4px;
}

.auth-tab {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label,
.password-form,
.invite-form {
  display: grid;
  gap: 7px;
}

.auth-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.auth-form button,
.password-form button,
.invite-form button {
  min-height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 0 16px;
}

.auth-form button:hover,
.password-form button:hover,
.invite-form button:hover {
  background: var(--accent-strong);
}

.auth-status {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns:
    minmax(180px, var(--tag-column-width)) var(--resizer-width)
    minmax(220px, var(--note-column-width)) var(--resizer-width) minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.app-shell.layout-notes {
  grid-template-columns: minmax(220px, var(--note-column-width)) var(--resizer-width) minmax(0, 1fr);
}

.app-shell.layout-editor {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.layout-notes .tag-panel,
.app-shell.layout-notes .column-resizer[data-resize-column="tag"],
.app-shell.layout-editor .tag-panel,
.app-shell.layout-editor .note-list-panel,
.app-shell.layout-editor .column-resizer {
  display: none;
}

.tag-panel,
.note-list-panel,
.editor-panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.tag-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.note-list-panel {
  display: flex;
  flex-direction: column;
}

.editor-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 0;
  padding: 22px 24px;
}

.column-resizer {
  position: relative;
  z-index: 2;
  min-width: var(--resizer-width);
  border: 0;
  background:
    linear-gradient(
      to right,
      transparent calc(50% - 0.5px),
      var(--line) calc(50% - 0.5px),
      var(--line) calc(50% + 0.5px),
      transparent calc(50% + 0.5px)
    );
  cursor: col-resize;
  touch-action: none;
}

.column-resizer::before {
  display: none;
  content: none;
}

.column-resizer:hover,
.column-resizer:focus-visible {
  background:
    linear-gradient(
      to right,
      transparent calc(50% - 0.5px),
      #c7ccd1 calc(50% - 0.5px),
      #c7ccd1 calc(50% + 0.5px),
      transparent calc(50% + 0.5px)
    );
  outline: none;
}

.column-resizer:hover::before,
.column-resizer:focus-visible::before {
  background: transparent;
}

body.is-resizing-columns {
  cursor: col-resize;
  user-select: none;
}

.panel-header,
.section-header,
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
}

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

.panel-header h1,
.section-header h2,
.editor-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

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

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--accent-strong);
  font-size: 24px;
  line-height: 1;
}

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

.user-row {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

#user-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-actions,
.password-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.user-actions button,
.password-form-actions button {
  min-height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
}

.password-form,
.invite-form {
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

.password-form input,
.invite-form input {
  height: 36px;
  font-size: 13px;
}

#invite-status {
  min-height: 18px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tag-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 16px;
}

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

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 280px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 100, 0.16);
}

.tag-form button,
.editor-actions button {
  min-height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0 16px;
}

.tag-form button:hover,
.editor-actions button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.danger-button {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

.icon-trash-button {
  display: grid;
  width: 36px;
  min-width: 36px;
  padding: 0;
  place-items: center;
}

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

.tag-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: auto;
  padding: 0 0 14px;
}

.tag-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  padding: 0 16px;
  text-align: left;
}

.tag-item:hover,
.tag-item.active {
  background: transparent;
}

.tag-item.active {
  color: var(--accent-strong);
  font-weight: 800;
}

.tag-item.trash {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.tag-name,
.note-preview {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-row {
  padding: 0 16px 16px;
}

.note-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: auto;
  padding: 0;
}

.note-card {
  display: block;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 16px;
  color: var(--text);
  text-align: left;
}

.note-card:hover,
.note-card.active {
  background: transparent;
}

.note-card.active {
  color: var(--accent-strong);
  font-weight: 800;
}

.note-card.active .note-preview,
.note-card.active .note-date {
  color: var(--accent-strong);
  font-weight: 800;
}

.note-preview {
  display: block;
  min-width: 0;
  overflow: hidden;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
}

.note-date {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 11px;
}

.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.editor {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: var(--shadow);
}

.editor-header {
  justify-content: flex-end;
  border-bottom: 0;
  padding: 0 0 16px;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.content-field {
  flex: 1;
  min-height: 0;
  padding-top: 0;
}

.content-field textarea {
  flex: 1;
  min-height: 0;
  border-color: transparent;
  background: transparent;
  font-size: 16px;
  line-height: 1.7;
  overflow: auto;
  resize: none;
}

.content-field textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.editor-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 0;
}

.editor-meta {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.tag-select {
  display: flex;
  min-width: 150px;
  flex-direction: column;
  gap: 6px;
}

.tag-select span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag-select select {
  height: 34px;
  font-size: 13px;
}

#saved-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .auth-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
    padding-top: 44px;
  }

  .auth-card {
    width: min(100%, 460px);
  }

  .app-shell {
    grid-template-columns:
      minmax(220px, min(var(--note-column-width), 44vw)) var(--resizer-width)
      minmax(0, 1fr);
  }

  .tag-panel,
  .column-resizer[data-resize-column="tag"] {
    display: none;
  }

  .editor {
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .auth-screen {
    padding: 18px;
  }

  .auth-nav {
    align-items: flex-start;
  }

  .auth-nav-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .auth-layout {
    padding: 42px 0 28px;
  }

  .auth-copy h1 {
    font-size: 42px;
  }

  .auth-lede {
    font-size: 16px;
  }

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

  .note-list-panel,
  .column-resizer[data-resize-column="note"] {
    display: none;
  }

  .editor-panel {
    padding: 12px;
  }

  .editor {
    min-height: 0;
  }

  .field {
    padding-right: 0;
    padding-left: 0;
  }

  .editor-actions {
    padding-right: 0;
    padding-left: 0;
  }
}
