:root {
  color-scheme: dark;
  --bg: #050914;
  --panel: #09101d;
  --panel-2: #0c1424;
  --panel-3: #111a2d;
  --line: rgba(144, 162, 205, 0.15);
  --line-2: rgba(144, 162, 205, 0.26);
  --text: #f4f7ff;
  --muted: #96a1b8;
  --soft: #c6cee0;
  --blue: #3157ff;
  --purple: #b54be5;
  --radius: 8px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(40, 88, 200, 0.13), transparent 42rem),
    linear-gradient(180deg, #050914 0%, #07101d 50%, #050914 100%);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  width: 1.12em;
  height: 1.12em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg {
  fill: currentColor;
  stroke: currentColor;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #7788ff;
  outline-offset: 2px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(4, 9, 17, 0.96);
  padding: 28px 24px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand strong {
  font-size: 29px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, #16d8ff 4%, #3356ff 42%, #bc44ea 88%);
  box-shadow: 0 0 26px rgba(109, 78, 255, 0.45);
  color: #fff;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  object-position: center;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.full-button {
  width: 100%;
}

.side-section-title {
  margin: 30px 0 16px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.folder-list {
  display: grid;
  gap: 6px;
}

.folder-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--soft);
  text-align: left;
  transition: 140ms ease;
}

.folder-button:hover {
  background: rgba(255, 255, 255, 0.035);
}

.folder-button.active {
  background: linear-gradient(90deg, rgba(190, 48, 116, 0.20), rgba(75, 75, 180, 0.13));
  box-shadow: inset 2px 0 0 #d93892;
  color: #fff;
}

.folder-topic-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 7px;
  color: #a484ff;
  background: rgba(117, 78, 255, 0.14);
}

.folder-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.folder-count {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.sidebar-profile {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: auto -24px -24px;
  padding: 20px 24px 22px;
  border-top: 1px solid var(--line);
  background: rgba(7, 13, 24, 0.62);
}

.sidebar-profile > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #3157ff, #9c48ee);
  font-weight: 800;
}

.sidebar-profile strong,
.sidebar-profile small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-profile strong {
  font-size: 13px;
}

.sidebar-profile small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.admin-exit {
  margin-top: 14px;
}

.main {
  min-width: 0;
  padding: 26px 38px 46px 28px;
}

.admin-header {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 4px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow span {
  margin: 0 10px;
  color: #61708d;
}

.folder-title-edit {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.folder-name {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 34px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
}

.folder-subtitle,
.toolbar-panel p,
.shared-hero p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.global-search,
.filter-search,
.filter-select {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 12, 22, 0.88);
  color: var(--muted);
}

.global-search {
  width: 235px;
  gap: 10px;
  padding: 0 14px;
}

.global-search input,
.filter-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
}

.global-search input::placeholder,
.filter-search input::placeholder {
  color: #818ba0;
}

.primary-button,
.ghost-button,
.ghost-link,
.icon-button,
.copy-action,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 20, 35, 0.92);
  color: var(--text);
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.ghost-link:hover,
.icon-button:hover,
.copy-action:hover,
.mini-button:hover {
  transform: translateY(-1px);
  border-color: rgba(151, 167, 205, 0.38);
}

.primary-button {
  padding: 0 18px;
  border-color: rgba(163, 86, 255, 0.72);
  background: linear-gradient(135deg, #3157ff, #bc49e4);
  font-weight: 700;
}

.ghost-button {
  padding: 0 17px;
}

.ghost-link {
  padding: 0 17px;
}

.icon-button {
  width: 44px;
  padding: 0;
}

.toolbar-panel,
.filter-shell,
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 15, 28, 0.74);
}

.toolbar-panel {
  margin-bottom: 20px;
  padding: 22px;
}

.toolbar-panel h2 {
  margin: 0;
  font-size: 15px;
}

.palette-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

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

.palette-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.palette-field small {
  color: var(--muted);
  font-size: 11px;
}

.swatch {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(145deg, var(--dark), var(--light));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.palette-item input,
.share-box input,
.filter-select select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 10, 19, 0.92);
  color: var(--text);
}

.palette-item input {
  min-height: 42px;
  padding: 0 12px;
}

.share-panel {
  display: grid;
  grid-template-columns: 58px 370px minmax(300px, 1fr);
  gap: 20px;
  align-items: center;
  min-height: 126px;
}

.auth-panel {
  display: grid;
  grid-template-columns: 58px minmax(260px, 1fr) minmax(280px, auto);
  gap: 20px;
  align-items: center;
}

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

.auth-form input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 10, 19, 0.92);
  color: var(--text);
  padding: 0 12px;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.auth-actions span {
  min-width: 0;
  overflow: hidden;
  color: var(--soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(5, 10, 19, 0.9);
}

.share-box input {
  min-height: 48px;
  border: 0;
  padding: 0 16px;
}

.share-box .primary-button {
  min-height: 48px;
  border-radius: 0;
}

.topic-icon,
.note-icon {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #cf78ff;
  background: rgba(139, 78, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(207, 120, 255, 0.20);
}

.topic-icon {
  width: 42px;
  height: 42px;
}

.topic-icon.large {
  width: 58px;
  height: 58px;
}

.filter-shell {
  margin-bottom: 16px;
  padding: 14px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 226px 216px 44px;
  gap: 12px;
}

.filter-search {
  gap: 10px;
  padding: 0 14px;
}

.filter-select select {
  min-height: 44px;
  padding: 0 42px 0 14px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #c8d1e6 50%) right 18px center / 7px 7px no-repeat,
    linear-gradient(135deg, #c8d1e6 50%, transparent 50%) right 12px center / 7px 7px no-repeat,
    rgba(5, 10, 19, 0.9);
}

.topic-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.topic-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(135, 151, 188, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  color: var(--soft);
  font-size: 13px;
}

.topic-pill span,
.filter-total {
  color: var(--muted);
}

.filter-total {
  margin-left: auto;
  font-size: 13px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 14px;
  align-items: stretch;
}

@media (min-width: 1450px) {
  .admin-notes {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.shared-notes {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.note-card {
  display: grid;
  grid-template-rows: 66px minmax(292px, 1fr);
  overflow: hidden;
  min-height: 414px;
  border: 1px solid color-mix(in srgb, var(--note-dark), white 22%);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--note-dark), transparent 48%) 0, rgba(12, 16, 28, 0.96) 66px),
    rgba(10, 15, 26, 0.96);
  box-shadow: none;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.note-card[hidden] {
  display: none !important;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.24);
}

.note-title {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 13px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--note-dark), white 12%);
  background: linear-gradient(135deg, color-mix(in srgb, var(--note-dark), black 5%), color-mix(in srgb, var(--note-dark), transparent 30%));
}

.note-icon {
  width: 34px;
  height: 34px;
  color: color-mix(in srgb, var(--note-light), white 15%);
  background: color-mix(in srgb, var(--note-dark), transparent 20%);
}

.note-title strong,
.title-select {
  min-width: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
}

.title-select {
  width: 100%;
  border: 0;
  appearance: none;
  background: transparent;
}

.title-select option {
  background: #101726;
  color: #fff;
}

.note-body {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
  padding: 17px 16px 14px;
}

.note-body label {
  display: grid;
  gap: 10px;
}

.note-body span {
  color: color-mix(in srgb, var(--note-light), white 24%);
  font-size: 14px;
  font-weight: 800;
}

.note-body p,
.note-body textarea {
  margin: 0;
  color: #f6f8ff;
  font-size: 14px;
  line-height: 1.56;
  white-space: pre-wrap;
}

.note-body p {
  min-height: 50px;
}

.note-body textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.note-body textarea:hover,
.note-body textarea:focus {
  background: rgba(255, 255, 255, 0.025);
  border-radius: 6px;
}

.note-body label + label {
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.note-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-self: end;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.copy-action {
  min-height: 39px;
  justify-content: flex-start;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 14px;
}

.copy-action svg {
  color: color-mix(in srgb, var(--note-light), white 8%);
}

.mini-button {
  width: 39px;
  min-height: 39px;
  padding: 0;
  color: #ffb6c4;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.stat-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 3px 18px;
  min-height: 122px;
  padding: 22px;
}

.stat-card svg {
  grid-row: span 3;
  width: 34px;
  height: 34px;
  align-self: center;
  color: #8fa2ff;
}

.stat-card span,
.stat-card small {
  color: var(--muted);
}

.stat-card strong {
  font-size: 22px;
}

.admin-login-page,
.public-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.admin-login-card,
.public-gate-panel {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 15, 28, 0.9);
  padding: 30px;
  text-align: center;
  box-shadow: var(--shadow);
}

.public-gate {
  align-content: center;
  gap: 26px;
}

.public-gate > .brand {
  justify-content: center;
}

.admin-login-card h1,
.public-gate-panel h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
}

.admin-login-card p,
.public-gate-panel p {
  margin: 8px 0 0;
  color: var(--muted);
}

.admin-password-field {
  display: grid;
  gap: 8px;
  width: 100%;
  text-align: left;
}

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

.admin-password-field input {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 10, 19, 0.92);
  color: var(--text);
  padding: 0 14px;
}

.admin-login-card .primary-button,
.public-gate-panel .ghost-link {
  width: 100%;
}

.shared-page {
  min-height: 100vh;
}

.shared-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0 38px;
  border-bottom: 1px solid var(--line);
}

.compact-brand {
  margin: 0;
}

.compact-brand strong {
  font-size: 26px;
}

.shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 12, 22, 0.65);
  color: var(--soft);
  font-size: 14px;
}

.shared-hero {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(100%, 980px);
  margin: 30px auto 22px;
  padding: 0 20px;
  text-align: center;
}

.shared-hero h1 {
  margin: 0;
  color: #fff;
  font-size: 39px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: 0;
}

.shared-hero p {
  margin-top: 8px;
  font-size: 15px;
}

.shared-content {
  width: min(100%, 1290px);
  margin: 0 auto;
  padding: 0 20px 34px;
}

.shared-page .filter-shell {
  margin-bottom: 20px;
}

.shared-page .topic-counts {
  display: none;
}

.shared-page .filter-bar {
  grid-template-columns: minmax(340px, 1fr) 224px 196px;
}

.shared-page .filter-bar .icon-button {
  display: none;
}

.shared-page .note-card {
  min-height: 324px;
  grid-template-rows: 66px minmax(258px, 1fr);
}

.shared-page .note-body {
  grid-template-rows: auto auto 1fr;
}

.shared-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 32px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.shared-footer span {
  width: 1px;
  height: 18px;
  background: var(--line-2);
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100vw - 28px);
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #f7f9ff;
  color: #101522;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(14px);
  transition: 180ms ease;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(151, 167, 205, 0.22);
}

@media (max-width: 1320px) {
  .admin-header,
  .share-panel,
  .auth-panel,
  .palette-panel {
    grid-template-columns: 1fr;
  }

  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .global-search {
    width: min(100%, 360px);
  }

  .filter-bar,
  .shared-page .filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .filter-bar .icon-button {
    width: auto;
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-profile {
    display: none;
  }

  .folder-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 22px 14px 32px;
  }

  .palette-grid,
  .stats-grid,
  .filter-bar,
  .shared-page .filter-bar {
    grid-template-columns: 1fr;
  }

  .notes-grid,
  .shared-notes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shared-topbar {
    display: grid;
    gap: 12px;
    padding: 16px 20px;
  }
}

@media (max-width: 620px) {
  .folder-list,
  .notes-grid,
  .shared-notes {
    grid-template-columns: 1fr;
  }

  .folder-title-edit {
    grid-template-columns: 1fr;
  }

  .folder-name,
  .shared-hero h1 {
    font-size: 31px;
  }

  .header-actions,
  .share-box,
  .auth-form,
  .auth-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .header-actions > *,
  .global-search {
    width: 100%;
  }
}
