:root {
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-strong: #f1f5f9;
  --line: #dfe5ee;
  --line-strong: #c8d2df;
  --text: #1f2937;
  --muted: #637083;
  --blue: #1a73e8;
  --blue-soft: #e8f0fe;
  --shadow: 0 2px 5px rgba(60, 64, 67, 0.18), 0 1px 2px rgba(60, 64, 67, 0.14);
  --shadow-strong: 0 12px 28px rgba(15, 23, 42, 0.18);
  --sidebar-width: 260px;
  --topbar-height: 64px;
  font-family: Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}

body.theme-dark {
  --bg: #202124;
  --surface: #292a2d;
  --surface-strong: #323235;
  --line: #3c4043;
  --line-strong: #5f6368;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --blue: #8ab4f8;
  --blue-soft: #2d333b;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-strong: 0 12px 30px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: var(--text);
}

::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

button {
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.icon-defs {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 8px 18px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(160%) blur(12px);
}

.icon-button,
.avatar-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:hover,
.avatar-button:hover,
.nav-item:hover {
  background: var(--surface-strong);
}

.icon-button:active,
.avatar-button:active {
  transform: scale(0.96);
}

.icon-button svg,
.brand-mark svg,
.nav-item svg,
.search-shell svg,
.text-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  color: var(--text);
  font-size: 21px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: white;
  background: linear-gradient(135deg, #5f6368, #9aa0a6);
  box-shadow: 0 5px 12px rgba(95, 99, 104, 0.22);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  max-width: 720px;
  height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid transparent;
  transition: background 140ms ease, border 140ms ease, box-shadow 140ms ease;
}

.search-shell:focus-within {
  background: var(--surface);
  border-color: #d4dce8;
  box-shadow: var(--shadow);
}

.search-shell input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.avatar-button {
  display: grid;
  place-items: center;
  color: white;
  background: #5f6368;
  font-size: 13px;
  font-weight: 700;
  padding: 0;
}

.avatar-button .avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

.avatar-button .avatar-fallback {
  position: absolute;
  display: none;
  place-items: center;
}

.avatar-button:has(.avatar-image[style*="display: none"]) .avatar-fallback {
  display: none;
}

.menu-anchor {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
}

.small-menu {
  width: 190px;
  padding: 8px;
}

.small-menu button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.small-menu button:hover {
  background: var(--surface-strong);
}

.account-menu {
  width: 300px;
  padding: 18px;
  text-align: center;
}

.close-popover {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.close-popover svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.close-popover:hover {
  background: var(--surface-strong);
}

.account-email {
  margin: 6px 20px 14px;
  color: var(--muted);
  font-size: 13px;
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 50%;
  color: white;
  background: #5f6368;
  font-size: 22px;
  font-weight: 700;
  overflow: hidden;
  position: relative;
}

.account-avatar .avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

.account-avatar .avatar-fallback {
  position: absolute;
  display: none;
  place-items: center;
}

.account-avatar:has(.avatar-image[style*="display: none"]) .avatar-fallback {
  display: none;
}

.secondary-button,
.signout-button,
.feedback-send {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--blue);
  font-weight: 600;
}

.secondary-button {
  margin: 14px 0 8px;
  padding: 9px 16px;
}

.signout-button {
  display: block;
  width: 100%;
  margin: 6px 0 14px;
  padding: 10px 14px;
  border-color: transparent;
  color: var(--text);
  background: var(--surface-strong);
}

.tiny-links {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.tiny-links a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.sidebar {
  position: sticky;
  top: var(--topbar-height);
  align-self: start;
  height: calc(100vh - var(--topbar-height));
  padding: 10px 12px;
  background: var(--bg);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-height: 48px;
  padding: 0 14px 0 0;
  border: 0;
  border-radius: 0 24px 24px 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item svg {
  justify-self: center;
}

.nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.active {
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 600;
}

.sidebar-labels {
  margin-top: 0;
  padding: 0 4px;
}

.sidebar-labels-title {
  display: none;
  margin: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-labels-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.sidebar-label-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-height: 48px;
  padding: 0 14px 0 0;
  border: 0;
  border-radius: 0 24px 24px 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.sidebar-label-item svg {
  justify-self: center;
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: none;
}

.sidebar-label-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-label-item.active {
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 600;
}

.sidebar-label-item:hover {
  background: var(--surface-strong);
}

body.sidebar-collapsed {
  --sidebar-width: 82px;
}

body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .sidebar-label-item {
  grid-template-columns: 1fr;
  width: 48px;
  height: 48px;
  min-height: 48px;
  margin: 0 auto;
  padding: 0;
  border-radius: 50%;
}

body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .sidebar-label-item span,
body.sidebar-collapsed .sidebar-labels-title {
  display: none;
}

.content {
  min-width: 0;
  padding: 28px clamp(16px, 3vw, 44px) 56px;
}

.composer-card {
  width: min(640px, 100%);
  margin: 0 auto 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer-collapsed {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 18px;
  border: 0;
  color: var(--muted);
  background: var(--surface);
  font-weight: 600;
  text-align: left;
}

.composer-expanded {
  padding: 12px 16px 10px;
}

.composer-top,
.editor-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-title,
.editor-title {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
  font-weight: 600;
}

.composer-title {
  height: 34px;
}

.composer-card textarea,
.editor-modal textarea,
.feedback-panel textarea {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  line-height: 1.5;
}

.composer-card textarea {
  min-height: 92px;
  margin-top: 4px;
}

.composer-footer,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.composer-tools,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.composer-label-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.composer-label-field select {
  min-width: 140px;
  max-width: 220px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
}

.color-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-right: auto;
}

.color-row.compact {
  margin: 0 0 0 4px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.color-swatch.active {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.close-save {
  min-width: 72px;
  padding: 8px 14px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  font-weight: 600;
}

.close-save:hover,
.text-only:hover,
.primary-text:hover {
  background: var(--surface-strong);
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 7px 4px;
}

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

.view-meta {
  width: min(1120px, 100%);
  margin: 0 auto 12px;
}

.trash-notice {
  margin: 0 0 24px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

.section-label {
  width: min(1120px, 100%);
  margin: 0 auto 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notes-section + .notes-section {
  margin-top: 30px;
}

.notes-grid {
  width: min(1120px, 100%);
  margin: 0 auto;
  column-width: 248px;
  column-gap: 16px;
}

.notes-grid.list-view {
  column-width: auto;
  column-count: 1;
  max-width: 660px;
}

.note-card {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0 0 16px;
  break-inside: avoid;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 55, 0.15);
  border-radius: 8px;
  background: var(--note-color, white);
  box-shadow: none;
  vertical-align: top;
  transition: box-shadow 140ms ease, transform 140ms ease, border-color 140ms ease;
}

.note-card:hover,
.note-card:focus-within {
  border-color: rgba(31, 41, 55, 0.26);
  box-shadow: var(--shadow);
}

.note-content {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 14px 14px 8px;
  outline: 0;
}

.note-content h3 {
  margin: 0 26px 8px 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.note-content p {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
}

.note-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.note-label {
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.note-content:focus-visible {
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.28);
}


.note-footer {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 42px;
  padding: 0 8px 8px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.note-card:hover .note-footer,
.note-card:focus-within .note-footer {
  opacity: 1;
}

.note-footer .icon-button {
  width: 34px;
  height: 34px;
}

.note-footer .color-swatch {
  width: 20px;
  height: 20px;
  opacity: 0.85;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 74px;
  height: 74px;
  margin-bottom: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
  opacity: 0.55;
}

.empty-state h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: start center;
  padding: 92px 18px 24px;
  background: rgba(32, 33, 36, 0.38);
}

.editor-modal,
.settings-modal,
.labels-modal {
  width: min(620px, 100%);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}

.editor-modal {
  padding: 16px;
  background: var(--note-color, white);
}

.editor-title {
  height: 38px;
  font-size: 18px;
}

.editor-modal textarea {
  min-height: 140px;
  padding-top: 8px;
}

.labels-input-label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.labels-input-label input,
.label-create-row input,
.label-edit-row input {
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  outline: 0;
  background: transparent;
  padding: 8px 0;
}

.settings-modal,
.labels-modal {
  max-width: 430px;
  padding: 18px;
}

.settings-modal h2,
.labels-modal h2,
.feedback-panel h2 {
  margin: 0 0 16px;
  font-size: 16px;
}

.settings-modal fieldset {
  display: grid;
  gap: 12px;
  padding: 0;
  border: 0;
}

.settings-modal legend {
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.settings-modal label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--text);
}

.settings-modal input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.text-only,
.primary-text {
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-weight: 600;
}

.primary-text {
  color: var(--blue);
}

.label-create-row,
.label-edit-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 6px;
}

.label-create-row .icon-button,
.label-edit-row .icon-button {
  width: 36px;
  height: 36px;
}

.labels-list {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow: auto;
  margin-top: 10px;
}

.feedback-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: 0;
  z-index: 80;
  width: min(380px, 100vw);
  padding: 18px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 28px rgba(15, 23, 42, 0.16);
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.feedback-panel label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.feedback-panel textarea {
  min-height: 148px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.feedback-panel p {
  color: var(--muted);
  font-size: 12px;
}

.feedback-check {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  margin-top: auto;
  font-weight: 400 !important;
}

.feedback-check input {
  margin-top: 2px;
  accent-color: var(--blue);
}

.feedback-send {
  position: absolute;
  right: 18px;
  bottom: 18px;
  padding: 9px 18px;
  color: white;
  background: var(--blue);
}

body.theme-dark .note-label {
  background: rgba(15, 23, 42, 0.35);
  color: #c5cfdd;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  background: var(--text);
  box-shadow: var(--shadow-strong);
}

.scrim {
  position: fixed;
  inset: var(--topbar-height) 0 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.24);
}

[hidden] {
  display: none !important;
}

[data-color="white"] {
  --note-color: #ffffff;
  --swatch: #ffffff;
}

[data-color="yellow"] {
  --note-color: #fff8b8;
  --swatch: #fff8b8;
}

[data-color="orange"] {
  --note-color: #fddfbc;
  --swatch: #fddfbc;
}

[data-color="red"] {
  --note-color: #ffd8d3;
  --swatch: #ffd8d3;
}

[data-color="blue"] {
  --note-color: #dceeff;
  --swatch: #dceeff;
}

[data-color="teal"] {
  --note-color: #cceeea;
  --swatch: #cceeea;
}

[data-color="green"] {
  --note-color: #dcf4d4;
  --swatch: #dcf4d4;
}

[data-color="purple"] {
  --note-color: #eadcf8;
  --swatch: #eadcf8;
}

body.theme-dark [data-color="white"] {
  --note-color: var(--surface);
  --swatch: var(--surface);
}

body.theme-dark [data-color="yellow"] {
  --note-color: #5c4d0a;
  --swatch: #5c4d0a;
}

body.theme-dark [data-color="orange"] {
  --note-color: #63360b;
  --swatch: #63360b;
}

body.theme-dark [data-color="red"] {
  --note-color: #5c1a1c;
  --swatch: #5c1a1c;
}

body.theme-dark [data-color="blue"] {
  --note-color: #0b3469;
  --swatch: #0b3469;
}

body.theme-dark [data-color="teal"] {
  --note-color: #0d4a4d;
  --swatch: #0d4a4d;
}

body.theme-dark [data-color="green"] {
  --note-color: #1a4f27;
  --swatch: #1a4f27;
}

body.theme-dark [data-color="purple"] {
  --note-color: #3b1d6b;
  --swatch: #3b1d6b;
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 82px;
  }

  .brand {
    min-width: auto;
  }

  .brand span:last-child {
    display: none;
  }

  .nav-item {
    grid-template-columns: 42px;
    width: 54px;
    padding-right: 0;
    border-radius: 50%;
  }

  .nav-item span {
    display: none;
  }

  .sidebar-labels {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    --topbar-height: 112px;
  }

  .topbar {
    gap: 6px;
    height: auto;
    min-height: var(--topbar-height);
    padding: 8px;
    flex-wrap: wrap;
  }

  .brand {
    min-width: 0;
  }

  .search-shell {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    height: 42px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    z-index: 40;
    width: 256px;
    transform: translateX(-104%);
    transition: transform 180ms ease;
    background: var(--surface);
    box-shadow: var(--shadow-strong);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .nav-item {
    grid-template-columns: 42px minmax(0, 1fr);
    width: 100%;
    padding-right: 14px;
    border-radius: 0 24px 24px 0;
  }

  .nav-item span {
    display: inline;
  }

  .content {
    padding: 22px 12px 48px;
  }

  .notes-grid {
    column-count: 1;
    column-width: auto;
  }

  .note-footer {
    opacity: 1;
  }

  .modal-backdrop {
    padding-top: 88px;
  }
}

@media (max-width: 520px) {
  .topbar-actions {
    gap: 0;
  }

  .icon-button,
  .avatar-button {
    width: 38px;
    height: 38px;
  }

  .composer-footer,
  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-label-field {
    width: 100%;
    justify-content: space-between;
  }

  .composer-label-field select {
    min-width: 0;
    flex: 1;
  }

  .color-row,
  .modal-actions {
    width: 100%;
  }

  .close-save {
    align-self: flex-end;
  }

  .account-menu {
    right: -4px;
    width: calc(100vw - 16px);
  }
}