:root {
  color-scheme: dark;
  --bg: #0f1117;
  --bg-soft: #121620;
  --panel: #171c26;
  --panel-soft: #1d2430;
  --panel-hover: #222a38;
  --field: #0f141d;
  --line: #2b3444;
  --line-soft: #202838;
  --text: #f1f6ff;
  --muted: #9aa8bc;
  --muted-2: #748197;
  --accent: #46b8ff;
  --accent-2: #7fd7ff;
  --accent-bg: #10263a;
  --danger: #ff6975;
  --danger-bg: #2a1720;
  --ok: #65d6a4;
  --radius: 8px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
  overflow-x: hidden;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

textarea {
  min-height: 360px;
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(70, 184, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(70, 184, 255, 0.13);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.svg-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
}

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

.login-panel {
  width: min(410px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand,
.brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.login-brand {
  gap: 13px;
  margin-bottom: 4px;
}

.login-panel h1 {
  margin: 0;
  font-size: 31px;
  line-height: 1.05;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, 240px) auto auto minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(15, 17, 23, 0.96);
  backdrop-filter: blur(18px);
  width: 100%;
  min-width: 0;
  max-width: 100vw;
}

.brand {
  gap: 11px;
  order: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(70, 184, 255, 0.5);
  border-radius: var(--radius);
  color: var(--accent-2);
  background: var(--accent-bg);
  font-weight: 950;
}

.brand strong,
.brand span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.site-switcher {
  order: 1;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.site-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.site-link:hover,
.site-link.active {
  color: var(--text);
  background: var(--panel-soft);
}

.login-switcher {
  width: 100%;
}

.login-switcher .site-link {
  flex: 1;
}

.search-wrap {
  position: relative;
  min-width: 0;
  order: 3;
}

.search-wrap input {
  padding-left: 38px;
}

.search-glyph {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted-2);
  border-radius: 999px;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-glyph::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: var(--muted-2);
  transform: rotate(45deg);
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  order: 4;
}

.top-actions > * {
  min-width: 0;
}

.tabs,
.segmented {
  order: 2;
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.tab-button,
.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  padding: 0 13px;
  font-weight: 850;
  white-space: nowrap;
}

.tab-button.active,
.segment.active {
  color: var(--text);
  background: var(--panel-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.primary-button,
.ghost-button,
.file-button,
.icon-button,
.mini-button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 850;
  white-space: nowrap;
}

.primary-button {
  color: #05111c;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(70, 184, 255, 0.16);
}

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

.ghost-button,
.file-button {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel-soft);
}

.ghost-button:hover,
.file-button:hover {
  border-color: rgba(70, 184, 255, 0.62);
  background: var(--panel-hover);
}

.ghost-button.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #51303a;
}

.wide {
  width: 100%;
}

.file-button {
  position: relative;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.slim {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 13px;
}

.icon-button {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  color: var(--muted);
  background: transparent;
}

.icon-button::before {
  content: "";
  width: 15px;
  height: 15px;
  background:
    linear-gradient(45deg, transparent 44%, currentColor 45%, currentColor 55%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, currentColor 45%, currentColor 55%, transparent 56%);
}

.icon-button:hover {
  color: var(--text);
  background: var(--panel-soft);
}

.main-shell {
  padding: 20px 18px 28px;
  min-width: 0;
  max-width: 100%;
}

.tab-panel {
  width: min(1380px, 100%);
  margin: 0 auto;
  min-width: 0;
  max-width: 100%;
}

.notes-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 88px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.panel-title {
  padding: 4px 6px 10px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.group-list {
  display: grid;
  gap: 4px;
}

.group-item {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 7px 8px;
  text-align: left;
}

.group-item:hover,
.group-item.active {
  background: var(--panel-soft);
  border-color: var(--line);
}

.group-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.group-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.group-count {
  min-width: 24px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  background: var(--field);
  font-size: 12px;
  font-weight: 850;
}

.group-tools {
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.group-item:hover .group-tools,
.group-item:focus-within .group-tools {
  opacity: 1;
}

.mini-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-color: var(--line);
  color: var(--muted);
  background: var(--field);
}

.mini-button:hover {
  color: var(--text);
  border-color: rgba(70, 184, 255, 0.64);
  background: var(--panel-hover);
}

.mini-button.danger:hover {
  color: var(--danger);
  border-color: #713846;
  background: var(--danger-bg);
}

.notes-area,
.media-layout {
  min-height: calc(100vh - 116px);
  min-width: 0;
}

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

.section-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.counter {
  min-width: 38px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--field);
  font-weight: 900;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
  min-width: 0;
}

.note-card {
  min-height: 205px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  min-width: 0;
  transition:
    transform 0.14s ease,
    border-color 0.14s ease,
    background 0.14s ease;
}

.note-card:hover,
.note-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(70, 184, 255, 0.52);
  background: var(--panel-soft);
  outline: none;
}

.note-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.note-body {
  margin: 0;
  color: #d4deed;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}

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

.note-tags {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--field);
  font-size: 12px;
  font-weight: 800;
}

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

.media-pill {
  color: var(--ok);
  border-color: rgba(101, 214, 164, 0.28);
  background: rgba(101, 214, 164, 0.08);
}

.card-actions {
  display: inline-flex;
  gap: 6px;
}

.media-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  min-width: 0;
}

.media-card,
.attached-item,
.picker-item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.media-card {
  display: grid;
  grid-template-rows: 158px auto auto;
  min-width: 0;
}

.media-card:hover {
  border-color: rgba(70, 184, 255, 0.52);
  background: var(--panel-soft);
}

.media-preview {
  width: 100%;
  height: 158px;
  display: grid;
  place-items: center;
  background: #0b1018;
  overflow: hidden;
}

.media-preview img,
.media-preview video,
.viewer-content img,
.viewer-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.media-info {
  display: grid;
  gap: 5px;
  padding: 11px;
}

.media-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-info span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.media-card-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 11px 11px;
}

.media-card-actions .mini-button {
  width: 100%;
}

.empty-state {
  min-height: 190px;
  display: grid;
  place-items: center;
  gap: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  padding: 24px;
  background: rgba(18, 22, 32, 0.42);
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 5, 10, 0.74);
}

.modal-dialog {
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.note-dialog {
  width: min(1080px, 100%);
}

.viewer-dialog {
  width: min(980px, 100%);
}

.name-dialog {
  width: min(440px, 100%);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-footer {
  border-top: 1px solid var(--line-soft);
  border-bottom: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.note-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px;
}

.note-fields {
  display: grid;
  gap: 14px;
}

.textarea-label {
  align-content: start;
}

.note-media-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line-soft);
}

.media-actions-row,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.attached-list,
.picker-list {
  display: grid;
  gap: 8px;
}

.attached-item,
.picker-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
}

.attached-thumb,
.picker-thumb {
  width: 58px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #0b1018;
  overflow: hidden;
}

.attached-thumb img,
.attached-thumb video,
.picker-thumb img,
.picker-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attached-info,
.picker-info {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.attached-info strong,
.picker-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.attached-actions,
.picker-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.media-picker {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.viewer-content {
  height: min(68vh, 680px);
  display: grid;
  place-items: center;
  padding: 16px;
  background: #080d14;
}

.name-dialog form {
  display: grid;
  gap: 16px;
}

.name-dialog label {
  padding: 0 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(70, 184, 255, 0.34);
  border-radius: var(--radius);
  background: #102033;
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 850;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .site-switcher {
    grid-column: 1 / -1;
  }

  .search-wrap {
    grid-column: 1 / -1;
    order: 3;
  }

  .top-actions {
    grid-column: 1 / -1;
    order: 4;
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1;
  }
}

@media (max-width: 860px) {
  .notes-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .group-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .group-item {
    min-width: 170px;
  }

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

  .note-media-panel {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    padding-top: 16px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 14px;
  }

  .topbar,
  .main-shell {
    padding: 12px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .brand,
  .site-switcher,
  .tabs,
  .top-actions {
    width: 100%;
  }

  .site-switcher {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tabs > *,
  .site-link,
  .top-actions > * {
    flex: 1;
  }

  .section-head,
  .media-toolbar,
  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .local-search {
    width: 100%;
  }

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

  .note-card {
    min-height: 190px;
  }

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

  .card-actions {
    justify-content: stretch;
  }

  .card-actions .mini-button {
    flex: 1;
    width: auto;
  }

  .media-card {
    grid-template-rows: 190px auto auto;
  }

  .media-preview {
    height: 190px;
  }

  .modal {
    padding: 10px;
  }

  .modal-dialog {
    max-height: calc(100vh - 20px);
  }

  .modal-header,
  .modal-footer,
  .note-editor-grid {
    padding: 12px;
  }

  textarea {
    min-height: 300px;
  }

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

  .modal-actions > *,
  .media-actions-row > * {
    flex: 1;
  }
}

@media (hover: none), (pointer: coarse) {
  .group-tools {
    opacity: 1;
  }

  .note-card:hover,
  .note-card:focus-visible,
  .media-card:hover {
    transform: none;
  }

  .mini-button,
  .icon-button {
    min-height: 44px;
  }

  .mini-button {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 620px) {
  .login-view {
    align-items: stretch;
    padding: 12px;
  }

  .login-panel {
    align-self: center;
    padding: 18px;
  }

  .login-panel h1 {
    font-size: 25px;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    padding: 10px 11px;
    font-size: 16px;
  }

  .topbar {
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .tabs,
  .site-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .site-switcher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab-button,
  .segment {
    min-height: 42px;
    padding: 0 8px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #logoutBtn {
    grid-column: 1 / -1;
  }

  .primary-button,
  .ghost-button,
  .file-button {
    min-height: 44px;
    padding-inline: 10px;
  }

  .main-shell {
    padding: 10px 8px 20px;
  }

  .sidebar {
    padding: 8px;
  }

  .group-list {
    gap: 8px;
    margin-inline: -2px;
    padding: 0 2px 4px;
    scrollbar-width: none;
  }

  .group-list::-webkit-scrollbar {
    display: none;
  }

  .group-item {
    min-width: 156px;
    min-height: 44px;
  }

  .section-head {
    gap: 8px;
    margin-bottom: 10px;
  }

  .section-head h2 {
    font-size: 20px;
  }

  .notes-grid,
  .media-grid {
    gap: 10px;
  }

  .tab-panel,
  .notes-layout,
  .notes-area,
  .notes-grid,
  .note-card,
  .media-layout,
  .media-grid,
  .media-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .notes-layout,
  .notes-grid,
  .media-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .note-card {
    min-height: 0;
    gap: 10px;
    padding: 12px;
  }

  .note-card h3 {
    font-size: 15px;
  }

  .note-body {
    -webkit-line-clamp: 5;
  }

  .card-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .card-actions .mini-button {
    width: 100%;
    height: 44px;
  }

  .media-toolbar {
    gap: 10px;
  }

  .segmented {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .media-card {
    grid-template-rows: 170px auto auto;
  }

  .media-preview {
    height: 170px;
  }

  .media-card-actions {
    gap: 8px;
  }

  .modal {
    align-items: stretch;
    padding: 0;
  }

  .modal-dialog {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }

  .modal-header,
  .modal-footer,
  .note-editor-grid {
    padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .note-editor-grid {
    gap: 12px;
  }

  .note-media-panel {
    gap: 10px;
    padding-top: 12px;
  }

  textarea {
    min-height: 34vh;
  }

  .viewer-content {
    height: calc(100dvh - 136px);
    padding: 10px;
  }

  .toast {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 20px);
  }
}

@media (max-width: 380px) {
  .brand span {
    display: none;
  }

  .group-item {
    min-width: 146px;
  }

  .primary-button,
  .ghost-button,
  .file-button,
  .tab-button,
  .segment {
    font-size: 13px;
  }
}

/* GOAT unified dark interface */
:root {
  --bg: #0b0d12;
  --bg-soft: #10131a;
  --panel: #151922;
  --panel-soft: #1a202b;
  --panel-hover: #202735;
  --field: #0d1016;
  --line: #29313e;
  --line-soft: #202632;
  --text: #f4f7fb;
  --muted: #929eaf;
  --muted-2: #687487;
  --accent: #7eb8ff;
  --accent-2: #b2d5ff;
  --accent-bg: #152338;
  --danger: #ff7f88;
  --danger-bg: #2b171d;
  --ok: #70d7aa;
  --radius: 14px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

body {
  background:
    radial-gradient(circle at 78% -15%, rgba(94, 145, 214, 0.13), transparent 34rem),
    var(--bg);
}

.login-panel {
  padding: 30px;
  border-radius: 20px;
  background: rgba(21, 25, 34, 0.94);
}

.brand-mark {
  border: 1px solid #3b4c64;
  border-radius: 12px;
  background: linear-gradient(145deg, #202c3f, #151c29);
  color: var(--accent-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

.topbar {
  grid-template-columns: minmax(180px, 220px) auto auto minmax(240px, 1fr) auto;
  gap: 14px;
  padding: 15px max(20px, calc((100vw - 1440px) / 2));
  background: rgba(11, 13, 18, 0.91);
  border-color: rgba(255, 255, 255, 0.08);
}

.site-switcher,
.tabs,
.segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 21, 29, 0.9);
}

.site-link,
.tab-button,
.segment {
  min-height: 36px;
  border-radius: 9px;
}

.site-link:hover,
.site-link.active,
.tab-button:hover,
.tab-button.active,
.segment:hover,
.segment.active {
  color: var(--text);
  background: var(--panel-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.main-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 70px;
}

.notes-layout {
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
}

.sidebar,
.notes-area,
.media-layout {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(18, 22, 30, 0.82);
}

.sidebar {
  padding: 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.2);
}

.notes-area,
.media-layout {
  padding: 24px;
}

.group-item {
  min-height: 44px;
  border-radius: 11px;
}

.group-item.active {
  color: var(--text);
  background: var(--accent-bg);
  box-shadow: inset 3px 0 0 var(--accent);
}

.notes-grid,
.media-grid {
  gap: 14px;
}

.note-card,
.media-card {
  border-color: var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(26, 32, 43, 0.96), rgba(19, 23, 31, 0.96));
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.16);
}

.note-card:hover,
.note-card:focus-visible,
.media-card:hover {
  border-color: #3c4b60;
  transform: translateY(-2px);
}

.primary-button,
.file-button {
  border-radius: 11px;
  border-color: #8cbfff;
  background: #8cbfff;
  color: #0a1320;
  box-shadow: none;
}

.primary-button:hover,
.file-button:hover {
  background: #a1cbff;
  border-color: #a1cbff;
}

.ghost-button,
.mini-button,
.icon-button {
  border-radius: 11px;
  background: #171c25;
}

input,
select,
textarea,
.search-wrap {
  border-radius: 11px;
}

.modal {
  background: rgba(2, 4, 8, 0.78);
  backdrop-filter: blur(9px);
}

.modal-dialog {
  border-radius: 20px;
  background: #12161e;
  box-shadow: 0 35px 110px rgba(0, 0, 0, 0.58);
}

.counter {
  color: var(--accent-2);
  background: var(--accent-bg);
}

.toast {
  border-radius: 13px;
  background: #1b2230;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(170px, 1fr) auto auto;
  }

  .topbar .search-wrap,
  .top-actions {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  .main-shell {
    width: min(100% - 24px, 1440px);
  }

  .sidebar,
  .notes-area,
  .media-layout {
    border-radius: 15px;
  }
}

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

  .topbar .search-wrap,
  .top-actions {
    grid-column: auto;
  }

  .login-switcher,
  .site-switcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-shell {
    width: calc(100% - 16px);
    padding-top: 10px;
  }

  .notes-area,
  .media-layout {
    padding: 14px;
  }
}
