:root {
  color-scheme: light;
  --bg: #f5f9fd;
  --bg-deep: #edf4fb;
  --surface: rgba(255, 255, 255, .94);
  --surface-soft: #f8fbfe;
  --surface-muted: #f2f6fb;
  --line: #e4edf7;
  --line-strong: #d8e4f2;
  --ink: #13234e;
  --muted: #69799e;
  --muted-light: #a7b4c9;
  --blue: #147df5;
  --blue-deep: #1169dc;
  --green: #0dad61;
  --green-deep: #079750;
  --red: #ff333b;
  --purple: #5b20d7;
  --shadow: 0 12px 34px rgba(41, 87, 147, .08);
  --shadow-large: 0 22px 55px rgba(51, 100, 160, .14);
  --radius: 16px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 52% 11%, rgba(255, 255, 255, .95), transparent 42%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-deep) 100%);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }
a { color: inherit; text-decoration: none; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.is-hidden { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 16px; color: var(--ink); font-weight: 750; }
.brand-mark {
  display: inline-grid;
  width: 50px;
  height: 50px;
  place-items: center;
  color: #fff;
  border-radius: 13px;
  background: linear-gradient(145deg, #1683ff 0%, #1e6eea 100%);
  box-shadow: 0 9px 18px rgba(20, 125, 245, .19);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -.8px;
}
.brand-name { font-size: 23px; letter-spacing: -.55px; }

/* Authentication */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 32px; }
.auth-card {
  width: min(100%, 630px);
  min-height: 520px;
  padding: 36px 40px 48px;
  border: 1px solid rgba(227, 237, 248, .9);
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-large);
}
.auth-brand { justify-content: center; margin: 0 auto 27px; }
.auth-brand .brand-mark { width: 62px; height: 62px; border-radius: 14px; font-size: 23px; }
.auth-brand .brand-name { font-size: 27px; }
.auth-screen h1 { margin: 0 0 38px; color: #15234c; text-align: center; font-size: 43px; line-height: 1.05; font-weight: 650; letter-spacing: -1.5px; }
.auth-screen form { display: grid; gap: 19px; }
.auth-screen input,
.modal-form input,
.modal-form textarea,
.modal-form select,
.whois-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, .9);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.auth-screen input { height: 70px; padding: 0 19px; font-size: 24px; }
.auth-screen input::placeholder { color: #a7b3c7; opacity: 1; }
.auth-screen input:focus,
.modal-form input:focus,
.modal-form textarea:focus,
.modal-form select:focus,
.whois-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(20, 125, 245, .11); }
.form-error { min-height: 0; margin: -8px 2px 0; color: #e32635; font-size: 14px; line-height: 1.4; }
.input-hint { margin: -9px 2px 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.input-hint.is-warning { color: #e32635; }
.auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 10px; }
.button {
  min-height: 53px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-primary { color: #fff; background: linear-gradient(135deg, #147df5, #1681f5); box-shadow: 0 7px 14px rgba(20, 125, 245, .18); }
.button-primary:hover { box-shadow: 0 10px 20px rgba(20, 125, 245, .25); }
.button-secondary { border-color: var(--line); color: var(--ink); background: #f7fafe; }
.button-secondary:hover, .button-outline:hover { border-color: #cfe0f5; background: #eef6ff; }
.button-success { color: #fff; background: linear-gradient(135deg, #12b86a, #06a957); box-shadow: 0 7px 14px rgba(5, 170, 88, .16); }
.button-success:hover { box-shadow: 0 10px 20px rgba(5, 170, 88, .23); }
.button-outline { border-color: #dce8f7; color: var(--blue-deep); background: #f8fbff; }
.button-wide { width: 100%; }
.button .icon { width: 25px; height: 25px; }
.auth-actions .button { min-height: 69px; font-size: 24px; }
.auth-message { margin: -11px 0 36px; color: #8b98b2; text-align: center; font-size: 24px; }

/* Main shell */
.app-page { padding: 0 12px 12px; }
.app-shell { min-height: calc(100vh - 12px); }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px 0 14px; }
.topbar-brand { gap: 17px; }
.topbar-brand .brand-mark { width: 50px; height: 50px; }
.topbar-user { display: flex; align-items: center; gap: 18px; }
.current-user { display: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.logout-button {
  min-width: 127px;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #ff3b42, #fb2d36);
  box-shadow: 0 8px 14px rgba(255, 51, 59, .16);
  font-size: 17px;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease;
}
.logout-button .icon { width: 24px; height: 24px; }
.logout-button:hover { transform: translateY(-1px); box-shadow: 0 11px 20px rgba(255, 51, 59, .23); }
.workspace { display: grid; grid-template-columns: 257px minmax(0, 1fr) 420px; gap: 9px; align-items: stretch; min-height: calc(100vh - 90px); }
.sidebar { display: flex; min-height: calc(100vh - 90px); flex-direction: column; justify-content: space-between; padding: 20px 0 0; }
.main-nav { display: grid; gap: 5px; }
.nav-item {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-right: 9px;
  padding: 0 24px;
  border-radius: 15px;
  color: #586b9c;
  font-size: 18px;
  font-weight: 450;
  transition: background .18s ease, color .18s ease;
}
.nav-item .icon { width: 26px; height: 26px; stroke-width: 1.9; }
.nav-item:hover { color: var(--blue); background: rgba(229, 240, 253, .72); }
.nav-item.is-active { color: var(--blue); background: linear-gradient(135deg, rgba(229, 240, 253, .92), rgba(222, 236, 253, .73)); }
.nav-item.nav-disabled { cursor: default; }
.nav-item.nav-disabled:hover { color: #586b9c; background: transparent; }
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }
body.is-admin .nav-item.admin-only { display: flex; }
.admin-only-view { display: none; }
body.is-admin .admin-only-view:not(.is-hidden) { display: block; }
.theme-control { width: 223px; height: 72px; display: flex; align-items: center; justify-content: center; gap: 17px; margin: 0 0 0 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255, 255, 255, .7); box-shadow: 0 4px 12px rgba(61, 111, 164, .04); }
.theme-icon { width: 24px; height: 24px; fill: none; stroke: #7281a6; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.theme-icon.moon { fill: #536992; stroke: #536992; }
.theme-toggle { width: 58px; height: 31px; position: relative; padding: 3px; border: 0; border-radius: 30px; background: var(--blue); transition: background .2s ease; }
.theme-toggle span { display: block; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(27, 77, 131, .18); transition: transform .2s ease; }
body[data-theme="dark"] .theme-toggle { background: #4c5c83; }
body[data-theme="dark"] .theme-toggle span { transform: translateX(27px); }

.main-content { min-width: 0; }
.surface-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.notes-card { min-height: calc(100vh - 90px); padding: 24px 25px 28px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-heading h1, .page-title-row h1 { margin: 0; color: var(--ink); font-size: 36px; line-height: 1.1; font-weight: 700; letter-spacing: -1.2px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 1px; }
.filter-tab { min-height: 36px; padding: 4px 13px; border: 0; border-radius: 7px; color: #6b6f78; background: #eef1f4; font-size: 20px; font-weight: 600; line-height: 1; transition: color .15s ease, background .15s ease; }
.filter-tab:hover { color: var(--blue); background: #e4edf8; }
.filter-tab.is-active { color: #fff; background: var(--blue); }
.heading-actions { display: flex; align-items: center; gap: 13px; margin-top: 1px; }
.heading-actions .button { min-height: 51px; padding-left: 17px; padding-right: 17px; font-size: 16px; }
.heading-actions .button .icon { width: 25px; height: 25px; }
.notes-list { display: grid; gap: 18px; }
.note-group { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .72); }
.note-group-header { min-height: 63px; display: flex; align-items: center; justify-content: space-between; padding: 0 23px; color: var(--ink); }
.note-group-title { display: inline-flex; align-items: center; gap: 21px; font-size: 20px; font-weight: 700; }
.note-group-title .icon { width: 27px; height: 27px; color: var(--blue); }
.group-toggle { display: inline-grid; width: 30px; height: 30px; place-items: center; border: 0; color: #5871a4; background: transparent; }
.group-toggle .icon { transition: transform .18s ease; }
.note-group.is-collapsed .group-toggle .icon { transform: rotate(180deg); }
.note-group.is-collapsed .note-group-items { display: none; }
.note-group-items { display: grid; gap: 8px; padding: 0 23px 15px; }
.note-item { overflow: hidden; border: 1px solid #e4ebf4; border-radius: 13px; background: linear-gradient(100deg, #f3f7fb, #edf2f8); }
.note-row { min-height: 61px; display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 20px; }
.note-title-toggle { min-width: 0; flex: 1; display: flex; align-items: center; gap: 11px; padding: 0; border: 0; color: var(--ink); background: transparent; text-align: left; font-size: 16px; line-height: 1.35; }
.note-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.personal-badge { flex: 0 0 auto; padding: 6px 15px; border-radius: 20px; color: #7485a6; background: #e8edf3; font-size: 14px; line-height: 1; }
.note-actions { display: flex; flex: 0 0 auto; gap: 9px; }
.icon-button { width: 46px; height: 46px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 10px; color: #fff; background: #aab6c8; transition: transform .15s ease, filter .15s ease, background .15s ease; }
.icon-button:hover { transform: translateY(-1px); filter: brightness(1.05); }
.icon-button .icon { width: 23px; height: 23px; }
.icon-button.edit { background: linear-gradient(145deg, #6726e4, #5920d4); }
.icon-button.copy { background: #b2becd; }
.icon-button.delete { background: linear-gradient(145deg, #ff3f43, #fb2935); }
.icon-button-light { width: 44px; height: 44px; border: 1px solid var(--line); color: var(--ink); background: #f7faff; }
.icon-button-light:hover { color: var(--blue); background: #eef6ff; }
.note-body { display: none; padding: 2px 20px 19px; color: #253762; white-space: pre-wrap; font-size: 16px; line-height: 1.55; }
.note-item.is-expanded .note-body { display: block; }
.note-title-toggle[aria-expanded="true"] .note-title-text { color: var(--blue-deep); }
.empty-state { display: grid; min-height: 220px; place-items: center; padding: 30px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-align: center; font-size: 16px; }

.links-sidebar { min-width: 0; }
.links-card { min-height: calc(100vh - 90px); padding: 25px 24px; }
.links-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 0 15px; }
.links-title { display: flex; align-items: center; gap: 20px; }
.links-title .icon { width: 29px; height: 29px; color: var(--blue); stroke-width: 2.1; }
.links-title h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.25px; }
.links-list { display: grid; gap: 8px; }
.link-card { min-height: 61px; display: flex; align-items: center; gap: 17px; padding: 8px 13px; border: 1px solid #e2eaf4; border-radius: 13px; background: linear-gradient(100deg, #f5f8fc, #f0f4f9); transition: border-color .15s ease, transform .15s ease; }
.link-card:hover { transform: translateY(-1px); border-color: #cbdcf0; }
.link-icon { width: 43px; height: 43px; display: inline-grid; flex: 0 0 auto; place-items: center; border-radius: 11px; color: #fff; }
.link-icon .icon { width: 24px; height: 24px; stroke-width: 2.2; }
.link-icon.blue { background: linear-gradient(145deg, #1584ff, #0873eb); }
.link-icon.green { background: linear-gradient(145deg, #16b86a, #06a958); }
.link-icon.orange { background: linear-gradient(145deg, #ff9d19, #f18409); }
.link-icon.purple { background: linear-gradient(145deg, #7729e8, #5e15cd); }
.link-icon.red { background: linear-gradient(145deg, #ff3d43, #ef242f); }
.link-icon.slate { background: linear-gradient(145deg, #778caf, #5d7198); }
.link-label { min-width: 0; flex: 1; overflow: hidden; color: #526891; font-size: 16px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.link-arrow { width: 20px; height: 20px; color: #526891; }
.links-empty { padding: 24px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.45; }

/* Internal pages */
.page-card { min-height: calc(100vh - 90px); padding: 31px 35px; }
.page-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-title-row p { max-width: 650px; margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.page-title-icon { width: 48px; height: 48px; color: var(--blue); fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.whois-form { padding: 28px 0 0; }
.whois-form label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 15px; font-weight: 650; }
.whois-input-row { display: flex; gap: 12px; }
.whois-form input { height: 53px; padding: 0 16px; font-size: 16px; }
.whois-input-row .button { min-width: 146px; }
.whois-result { margin-top: 27px; padding-top: 25px; border-top: 1px solid var(--line); }
.result-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 16px; }
.result-source { padding: 6px 11px; border-radius: 8px; color: #fff; background: var(--blue); font-size: 13px; font-weight: 700; }
.result-target { color: var(--muted); font-size: 14px; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.result-field { min-height: 59px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.result-field-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.result-field-value { color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.result-list { margin: 18px 0 0; padding: 0; list-style: none; }
.result-list li { padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.raw-result { margin-top: 18px; }
.raw-result summary { cursor: pointer; color: var(--blue-deep); font-size: 14px; font-weight: 650; }
.raw-result pre, .raw-result-pre { max-height: 430px; overflow: auto; margin: 10px 0 0; padding: 15px; border-radius: 10px; color: #dce9ff; background: #162342; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; padding-top: 24px; }
.users-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 14px; }
.users-table th { padding: 0 13px 5px; color: var(--muted); text-align: left; font-size: 12px; font-weight: 650; }
.users-table td { padding: 14px 13px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-soft); white-space: nowrap; }
.users-table td:first-child { border-left: 1px solid var(--line); border-radius: 10px 0 0 10px; color: var(--ink); font-weight: 650; }
.users-table td:last-child { border-right: 1px solid var(--line); border-radius: 0 10px 10px 0; }
.role-select { min-height: 35px; padding: 4px 9px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; font-size: 13px; }
.status-badge { display: inline-block; padding: 5px 8px; border-radius: 20px; color: #5871a4; background: #e9eff7; font-size: 12px; }
.status-badge.active { color: #0b9553; background: #ddf6e9; }
.table-delete { width: 36px; height: 36px; }

/* Modals */
.modal-backdrop { position: fixed; z-index: 20; inset: 0; background: rgba(12, 29, 62, .38); backdrop-filter: blur(4px); }
.modal { position: fixed; z-index: 21; top: 50%; left: 50%; width: min(640px, calc(100vw - 30px)); max-height: calc(100vh - 30px); overflow: auto; transform: translate(-50%, -50%); padding: 26px 29px 29px; box-shadow: 0 28px 70px rgba(21, 43, 80, .25); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 21px; }
.modal-header h2 { margin: 0; color: var(--ink); font-size: 26px; letter-spacing: -.7px; }
.modal-close { width: 38px; height: 38px; color: var(--muted); background: var(--surface-muted); }
.modal-close:hover { color: var(--ink); background: #e6eef8; }
.modal-form { display: grid; gap: 9px; }
.modal-form > label, .modal-form .visibility-field label { margin-top: 4px; color: var(--ink); font-size: 14px; font-weight: 650; }
.modal-form input, .modal-form select { height: 47px; padding: 0 13px; font-size: 15px; }
.modal-form textarea { min-height: 140px; padding: 12px 13px; resize: vertical; font-size: 15px; line-height: 1.5; }
.modal-form select { appearance: auto; }
.category-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 2px 0 5px; }
.category-option { position: relative; display: flex; align-items: center; min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; color: #5f7197; background: var(--surface-soft); cursor: pointer; font-size: 13px; font-weight: 500; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.category-option:has(input:checked) { border-color: #8bc1ff; color: var(--blue-deep); background: #eaf4ff; }
.category-option input { position: absolute; opacity: 0; pointer-events: none; }
.visibility-field { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 12px; }
.visibility-field label { margin: 0 !important; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.modal-actions .button { min-width: 135px; min-height: 46px; font-size: 15px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.two-fields > div { display: grid; gap: 8px; }
.compact-form { gap: 9px; }
.managed-list { display: grid; gap: 8px; max-height: 310px; overflow: auto; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.managed-row { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.managed-row-main { min-width: 0; flex: 1; }
.managed-row-title { overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.managed-row-subtitle { overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.managed-row-actions { display: flex; flex: 0 0 auto; gap: 4px; }
.managed-row-actions .icon-button { width: 31px; height: 31px; border-radius: 8px; color: var(--muted); background: transparent; }
.managed-row-actions .icon-button:hover { color: var(--blue); background: #eaf3ff; }
.managed-row-actions .icon-button.danger:hover { color: var(--red); background: #fff0f0; }
.managed-row-actions .icon-button .icon { width: 18px; height: 18px; }

.toast-root { position: fixed; z-index: 40; right: 22px; bottom: 22px; display: grid; gap: 9px; width: min(370px, calc(100vw - 44px)); }
.toast { padding: 13px 16px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fff; box-shadow: 0 12px 30px rgba(36, 74, 123, .16); font-size: 14px; line-height: 1.4; animation: toast-in .2s ease; }
.toast.success { border-color: #bcebd2; }
.toast.error { border-color: #ffc7cb; color: #b6212b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal-open { overflow: hidden; }

/* Dark theme */
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10192c;
  --bg-deep: #0e1626;
  --surface: rgba(22, 34, 56, .96);
  --surface-soft: #182641;
  --surface-muted: #202f4b;
  --line: #2b3b59;
  --line-strong: #3b4d6e;
  --ink: #edf4ff;
  --muted: #a7b5cf;
  --muted-light: #7f91b3;
  --shadow: 0 12px 34px rgba(0, 0, 0, .18);
  background: radial-gradient(circle at 52% 11%, rgba(42, 62, 97, .55), transparent 42%), linear-gradient(135deg, var(--bg), var(--bg-deep));
}
body[data-theme="dark"] .brand, body[data-theme="dark"] .section-heading h1, body[data-theme="dark"] .page-title-row h1, body[data-theme="dark"] .links-title h2, body[data-theme="dark"] .modal-header h2 { color: var(--ink); }
body[data-theme="dark"] .nav-item { color: #a4b2ce; }
body[data-theme="dark"] .nav-item:hover, body[data-theme="dark"] .nav-item.is-active { color: #63a9ff; background: rgba(40, 73, 124, .55); }
body[data-theme="dark"] .nav-item.nav-disabled:hover { color: #a4b2ce; background: transparent; }
body[data-theme="dark"] .theme-control { background: rgba(24, 38, 65, .8); }
body[data-theme="dark"] .note-group, body[data-theme="dark"] .note-item { background: #15233b; }
body[data-theme="dark"] .note-item { border-color: #2e4161; }
body[data-theme="dark"] .note-row, body[data-theme="dark"] .link-card { background: linear-gradient(100deg, #1c2d4a, #172640); border-color: #2e4161; }
body[data-theme="dark"] .note-title-toggle, body[data-theme="dark"] .note-body { color: #e3edff; }
body[data-theme="dark"] .personal-badge, body[data-theme="dark"] .status-badge { color: #aebdd7; background: #2a3a57; }
body[data-theme="dark"] .button-secondary, body[data-theme="dark"] .button-outline, body[data-theme="dark"] .icon-button-light { color: var(--ink); background: #1a2a46; border-color: #354b70; }
body[data-theme="dark"] .filter-tab { color: #aeb9cb; background: #26354e; }
body[data-theme="dark"] .filter-tab.is-active { color: #fff; background: var(--blue); }
body[data-theme="dark"] .auth-card, body[data-theme="dark"] .auth-screen input, body[data-theme="dark"] .modal-form input, body[data-theme="dark"] .modal-form textarea, body[data-theme="dark"] .modal-form select, body[data-theme="dark"] .whois-form input { color: var(--ink); background: #182641; border-color: #3b4d6e; }
body[data-theme="dark"] .auth-screen h1, body[data-theme="dark"] .auth-screen input::placeholder { color: var(--ink); }
body[data-theme="dark"] .auth-screen input::placeholder { color: #8f9fbb; }
body[data-theme="dark"] .category-option { color: #b7c4da; background: #1a2a46; border-color: #354b70; }
body[data-theme="dark"] .category-option:has(input:checked) { color: #74b4ff; background: #1d3d66; border-color: #4f9cff; }
body[data-theme="dark"] .managed-row, body[data-theme="dark"] .result-field, body[data-theme="dark"] .users-table td { background: #1a2a46; border-color: #354b70; }
body[data-theme="dark"] .role-select { color: var(--ink); background: #1a2a46; border-color: #435a80; }
body[data-theme="dark"] .link-label, body[data-theme="dark"] .link-arrow { color: #b8c6df; }
body[data-theme="dark"] .toast { color: var(--ink); background: #1a2a46; border-color: #3b4d6e; }

body.is-admin .visibility-field.admin-only { display: grid; }

@media (min-width: 1450px) {
  .current-user { display: inline; }
}

@media (max-width: 1250px) {
  .workspace { grid-template-columns: 210px minmax(0, 1fr); }
  .links-sidebar { grid-column: 2; }
  .links-card { min-height: 0; }
  .links-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-page { padding: 0 7px 7px; }
  .topbar { height: 72px; padding: 0 8px; }
  .brand-name { font-size: 19px; }
  .topbar-brand .brand-mark { width: 43px; height: 43px; border-radius: 11px; font-size: 16px; }
  .logout-button { min-width: 48px; width: 48px; padding: 0; }
  .logout-button span { display: none; }
  .workspace { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
  .sidebar { min-height: 0; order: 1; padding: 0; }
  .main-content { order: 2; }
  .links-sidebar { order: 3; }
  .main-nav { display: flex; overflow-x: auto; gap: 4px; padding: 0 2px 5px; }
  .nav-item { min-height: 46px; flex: 0 0 auto; gap: 8px; margin: 0; padding: 0 13px; border-radius: 11px; font-size: 14px; }
  .nav-item .icon { width: 21px; height: 21px; }
  .theme-control { position: absolute; top: 79px; right: 10px; width: auto; height: 43px; gap: 7px; padding: 0 8px; border-radius: 11px; }
  .theme-icon { width: 17px; height: 17px; }
  .theme-toggle { width: 42px; height: 24px; padding: 3px; }
  .theme-toggle span { width: 18px; height: 18px; }
  body[data-theme="dark"] .theme-toggle span { transform: translateX(18px); }
  .notes-card, .links-card, .page-card { min-height: 0; padding: 20px 14px; }
  .section-heading { display: grid; gap: 14px; }
  .section-heading h1, .page-title-row h1 { font-size: 30px; }
  .heading-actions { flex-wrap: wrap; }
  .heading-actions .button { flex: 1; }
  .filter-tab { font-size: 15px; }
  .note-group-header { padding: 0 14px; }
  .note-group-items { padding-left: 10px; padding-right: 10px; }
  .note-row { align-items: flex-start; padding: 10px; }
  .note-title-toggle { align-items: flex-start; padding-top: 7px; font-size: 14px; }
  .note-title-text { white-space: normal; }
  .personal-badge { display: none; }
  .note-actions { gap: 4px; }
  .icon-button { width: 37px; height: 37px; }
  .links-list { grid-template-columns: 1fr; }
  .whois-input-row { display: grid; }
  .whois-input-row .button { width: 100%; }
  .result-grid, .two-fields, .category-options { grid-template-columns: 1fr; }
  .modal { padding: 21px 17px 20px; }
  .auth-page { padding: 15px; }
  .auth-card { min-height: 0; padding: 27px 19px 30px; }
  .auth-brand { margin-bottom: 29px; }
  .auth-brand .brand-mark { width: 51px; height: 51px; font-size: 19px; }
  .auth-brand .brand-name { font-size: 22px; }
  .auth-screen h1 { margin-bottom: 28px; font-size: 34px; }
  .auth-screen input { height: 57px; font-size: 17px; }
  .auth-actions { gap: 9px; }
  .auth-actions .button { min-height: 56px; font-size: 17px; }
  .auth-message { font-size: 18px; }
}
