:root {
  color-scheme: light;
  --page: #f6f7fb;
  --sidebar: #fff;
  --surface: #fff;
  --surface-soft: #fafaff;
  --text: #202138;
  --muted: #85869a;
  --subtle: #a7a8b7;
  --line: #eeeff5;
  --primary: #635bda;
  --primary-hover: #5149c8;
  --primary-soft: #f0efff;
  --green: #2aa67a;
  --shadow: 0 7px 26px rgba(37, 39, 78, .045);
  --card-shadow: 0 4px 16px rgba(35, 38, 76, .035);
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--page); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(99, 91, 218, .28); outline-offset: 2px; }
.app-shell { min-height: 100vh; }

.sidebar {
  width: 254px; position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--line); padding: 27px 17px 17px;
}
.brand { display: flex; align-items: center; gap: 11px; height: 45px; margin: 0 0 42px 7px; color: var(--text); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); }
.brand-mark svg { width: 25px; height: 25px; fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.3; }
.brand-name { font: 800 24px/21px 'Manrope', sans-serif; letter-spacing: -1.5px; }
.brand-name > span { color: var(--primary); }
.brand-name small { display: block; margin-top: 5px; color: var(--muted); font: 700 8px/1 'DM Sans', sans-serif; letter-spacing: 1.1px; }
.sidebar-label { padding: 0 11px; color: #a3a4b3; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; }
.primary-nav { display: grid; gap: 4px; margin: 13px 0 29px; }
.nav-item {
  width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 11px;
  border: 0; border-radius: 9px; background: transparent; color: #77788d; text-align: left; cursor: pointer; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-soft); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-icon { width: 18px; text-align: center; color: #9293a7; font-size: 18px; line-height: 1; }
.nav-item.active .nav-icon { color: var(--primary); }
.favorite-icon { font-size: 20px; }
.nav-count { margin-left: auto; color: var(--subtle); font-size: 11px; font-weight: 600; }
.nav-item.active .nav-count { color: var(--primary); }
.category-heading { display: flex; align-items: center; justify-content: space-between; padding-right: 6px; margin-bottom: 9px; }
.category-list { display: grid; gap: 2px; overflow-y: auto; }
.category-item { min-height: 39px; gap: 9px; padding-right: 4px; }
.category-item .category-label { overflow: hidden; flex: 1; text-overflow: ellipsis; white-space: nowrap; }
.category-dot { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 auto; background: var(--dot, #9b91e9); }
.category-controls { display: none; gap: 1px; }
.category-item:hover .category-controls, .category-item:focus-within .category-controls { display: flex; }
.category-control { border: 0; background: none; color: #9293a7; padding: 3px; cursor: pointer; font-size: 12px; }
.category-control:hover { color: var(--primary); }
.category-control:disabled { opacity: .35; cursor: not-allowed; }
.category-count { font-size: 11px; color: var(--subtle); }
.small-icon { width: 27px !important; height: 27px !important; border-radius: 7px !important; font-size: 18px !important; }
.sidebar-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.utility-item { min-height: 36px; font-size: 12px; gap: 10px; }
.utility-item .nav-icon { font-size: 16px; }
.storage-note { display: flex; align-items: center; gap: 8px; margin: 17px 10px 0; color: var(--muted); font-size: 10px; }
.storage-dot { width: 7px; height: 7px; border-radius: 50%; background: #49bd8b; box-shadow: 0 0 0 3px rgba(73, 189, 139, .12); }

.main-content { min-height: 100vh; margin-left: 254px; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 5.2%; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.62); }
.breadcrumb { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.breadcrumb strong { color: var(--text); font-weight: 600; }
.breadcrumb-slash { color: #c1c2ce; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { display: inline-grid; place-items: center; width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: #77788b; cursor: pointer; transition: .15s; }
.icon-button:hover { border-color: #dbd9f9; color: var(--primary); }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 9px; border: 1px solid transparent; border-radius: 9px; padding: 0 16px; font-weight: 600; cursor: pointer; transition: background .15s, transform .15s, border-color .15s; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 11px rgba(99, 91, 218, .18); }
.button-primary:hover { background: var(--primary-hover); }
.button-plus { font-size: 20px; font-weight: 400; line-height: 1; }
.button-quiet { border-color: var(--line); background: var(--surface); color: #77788b; }
.button-quiet:hover { border-color: #d7d6e7; color: var(--text); }
.mobile-menu { display: none; }
.content-wrap { width: min(1120px, 100%); margin: 0 auto; padding: 42px 5.2% 25px; }
.welcome-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 27px; }
.eyebrow { margin: 0 0 10px; color: var(--primary); font-size: 10px; font-weight: 700; letter-spacing: 1.15px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font: 700 clamp(25px, 3vw, 33px)/1.2 'Manrope', sans-serif; letter-spacing: -1.25px; }
h1 span { color: var(--primary); }
.page-subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.stats { display: flex; gap: 10px; }
.stat-card { display: flex; align-items: center; gap: 10px; min-width: 132px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: var(--card-shadow); }
.stat-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; font-size: 17px; }
.link-stat { background: #f0efff; color: var(--primary); }
.category-stat { background: #eaf8f2; color: #33a27c; }
.stat-card strong { display: block; font: 700 17px/18px 'Manrope', sans-serif; }
.stat-card div > span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.search-panel { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border: 1px solid #e8e8f0; border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); }
.search-icon { color: #999aac; font-size: 24px; line-height: 1; transform: rotate(-20deg); }
.search-panel input { min-width: 50px; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.search-panel input::placeholder { color: #a0a1b1; }
kbd { border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; color: #a0a1b1; font: 10px 'DM Sans', sans-serif; }
.search-divider { height: 23px; width: 1px; margin: 0 5px; background: var(--line); }
.sort-label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.search-panel select { width: 126px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 11px; cursor: pointer; }

.section-block { margin-top: 36px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-heading > div { display: flex; align-items: center; gap: 8px; }
.section-heading h2 { margin: 0; font: 700 16px/1.3 'Manrope', sans-serif; letter-spacing: -.3px; }
.section-symbol { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; font-size: 15px; }
.favorite-symbol { color: #e8a747; background: #fff7e8; }
.links-symbol { color: var(--primary); background: var(--primary-soft); }
.section-count { display: inline-grid; min-width: 21px; height: 20px; place-items: center; border-radius: 6px; background: #efeff5; color: #85869a; font-size: 10px; font-weight: 700; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.text-button:hover { color: var(--primary); }
.text-button span { margin-left: 4px; font-size: 15px; }
.link-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.compact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.link-card {
  position: relative; min-width: 0; min-height: 156px; padding: 15px 15px 13px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); box-shadow: var(--card-shadow); transition: transform .16s, box-shadow .16s, border-color .16s;
}
.link-card:hover { transform: translateY(-2px); border-color: #e0def8; box-shadow: 0 9px 22px rgba(35, 38, 76, .07); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.site-identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.site-icon-wrap { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--primary); font: 700 13px 'Manrope', sans-serif; }
.site-icon-wrap img { width: 22px; height: 22px; object-fit: contain; }
.site-title-wrap { min-width: 0; }
.site-title { display: block; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.site-title:hover { color: var(--primary); }
.site-domain { overflow: hidden; display: block; margin-top: 4px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.card-menu { position: relative; display: flex; gap: 2px; margin: -4px -6px 0 0; opacity: .5; transition: opacity .15s; }
.link-card:hover .card-menu, .card-menu:focus-within { opacity: 1; }
.card-action { width: 27px; height: 27px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #9697aa; cursor: pointer; font-size: 15px; }
.card-action:hover { background: var(--surface-soft); color: var(--primary); }
.card-action.is-favorite { color: #e5a331; }
.card-description { display: -webkit-box; min-height: 30px; overflow: hidden; margin: 13px 0 10px; color: var(--muted); font-size: 10px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.category-pill { max-width: 70%; overflow: hidden; border-radius: 5px; padding: 4px 7px; background: var(--surface-soft); color: #77788d; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.open-link { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); font-size: 10px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.open-link:hover { color: var(--primary-hover); }
.open-link span { font-size: 14px; }
.empty-state { padding: 54px 15px 58px; border: 1px dashed #dedeea; border-radius: 13px; background: rgba(255,255,255,.46); text-align: center; }
.empty-state[hidden] { display: none; }
.empty-illustration { position: relative; width: 62px; height: 56px; margin: 0 auto 19px; border: 1px solid #e5e3fc; border-radius: 17px; background: #f2f1ff; color: var(--primary); }
.empty-illustration span { position: absolute; top: 10px; left: 21px; font-size: 26px; }
.empty-illustration i, .empty-illustration b { position: absolute; width: 7px; height: 7px; border-radius: 2px; background: #aaa4ed; }
.empty-illustration i { top: -4px; right: 2px; }
.empty-illustration b { bottom: 1px; left: -5px; width: 5px; height: 5px; background: #6bc7a3; }
.empty-state h3 { margin-bottom: 7px; font: 700 15px 'Manrope', sans-serif; }
.empty-state p { margin: 0 auto 18px; color: var(--muted); font-size: 12px; }
.empty-state .button { min-height: 37px; font-size: 11px; }
.footer-note { display: flex; justify-content: space-between; margin-top: 43px; padding-top: 16px; border-top: 1px solid var(--line); color: #a0a1b0; font-size: 10px; }
.footer-note span { color: #a0a1b0; }

.modal { width: min(500px, calc(100% - 30px)); max-height: min(90vh, 760px); overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; padding: 25px; background: var(--surface); color: var(--text); box-shadow: 0 22px 80px rgba(30, 30, 70, .2); }
.modal::backdrop { background: rgba(22, 23, 45, .38); backdrop-filter: blur(2px); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 23px; }
.modal-heading .eyebrow { margin-bottom: 6px; }
.modal-heading h2 { margin: 0; font: 700 21px 'Manrope', sans-serif; letter-spacing: -.5px; }
.close-dialog { width: 31px; height: 31px; font-size: 22px; }
.form-field { display: block; margin-bottom: 17px; color: var(--text); font-size: 11px; font-weight: 700; }
.required { color: #e06b70; }
.optional { color: var(--muted); font-size: 10px; font-weight: 400; }
.form-field input, .form-field select, .form-field textarea { width: 100%; display: block; margin-top: 7px; border: 1px solid #e8e8f0; border-radius: 8px; padding: 10px 11px; background: var(--surface); color: var(--text); font-size: 12px; font-weight: 400; }
.form-field input, .form-field select { min-height: 40px; }
.form-field textarea { resize: vertical; min-height: 74px; }
.form-field input::placeholder, .form-field textarea::placeholder { color: #adaebb; }
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 400; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 23px; }
.modal-actions .button { min-height: 38px; font-size: 11px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: grid; gap: 8px; }
.toast { max-width: min(380px, calc(100vw - 40px)); display: flex; align-items: center; gap: 9px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: 0 8px 30px rgba(30,30,70,.15); font-size: 12px; animation: toast-in .18s ease-out; }
.toast::before { content: ''; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #43b789; }
.toast.error::before { background: #df696c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.sidebar-backdrop { display: none; }

body.dark {
  color-scheme: dark;
  --page: #171821; --sidebar: #1d1e29; --surface: #22232f; --surface-soft: #292a38; --text: #f0f0f6;
  --muted: #a0a1b4; --subtle: #77798d; --line: #30313f; --primary: #9c95ff; --primary-hover: #827af0;
  --primary-soft: #302e4d; --shadow: 0 7px 26px rgba(0,0,0,.12); --card-shadow: 0 4px 16px rgba(0,0,0,.1);
}
body.dark .topbar { background: rgba(29,30,41,.75); }
body.dark .link-stat { background: #302e4d; }
body.dark .category-stat { background: #213a33; }
body.dark .favorite-symbol { background: #393225; }
body.dark .empty-state { background: rgba(34,35,47,.6); }
body.dark .empty-illustration { background: #302e4d; border-color: #48446e; }
body.dark .section-count { background: #30313f; }

@media (min-width: 1450px) {
  .content-wrap { padding-right: 58px; padding-left: 58px; }
  .topbar { padding-right: max(58px, calc((100% - 1120px) / 2 + 58px)); padding-left: max(58px, calc((100% - 1120px) / 2 + 58px)); }
}
@media (max-width: 1100px) {
  .sidebar { width: 225px; }
  .main-content { margin-left: 225px; }
  .content-wrap { padding-right: 4%; padding-left: 4%; }
  .topbar { padding-right: 4%; padding-left: 4%; }
  .link-grid, .compact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { min-width: 115px; padding: 9px; }
}
@media (max-width: 760px) {
  .sidebar { width: 275px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 12px 0 30px rgba(20,20,50,.08); }
  body.menu-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 19; background: rgba(20,20,40,.35); }
  body.menu-open .sidebar-backdrop { display: block; }
  .main-content { margin-left: 0; }
  .topbar { height: 64px; padding: 0 17px; }
  .mobile-menu { display: inline-grid; width: 35px; height: 35px; border: 0; background: transparent; font-size: 18px; }
  .breadcrumb { margin-right: auto; margin-left: 10px; }
  .topbar-actions { gap: 7px; }
  .top-theme-button { display: none; }
  .top-add-button { min-height: 36px; padding: 0 11px; font-size: 11px; }
  .content-wrap { padding: 29px 18px 22px; }
  .welcome-row { align-items: flex-start; flex-direction: column; gap: 17px; margin-bottom: 20px; }
  .stats { width: 100%; }
  .stat-card { flex: 1; }
  .search-panel { height: 49px; gap: 9px; padding: 0 11px; }
  kbd, .search-divider, .sort-label, .search-panel select { display: none; }
  .search-icon { font-size: 22px; }
  .search-panel input { font-size: 12px; }
  .section-block { margin-top: 29px; }
  .link-grid, .compact-grid { gap: 10px; }
  .link-card { min-height: 151px; padding: 12px; }
  .card-menu { opacity: 1; }
}
@media (max-width: 480px) {
  h1 { font-size: 25px; }
  .page-subtitle { font-size: 12px; }
  .stats { gap: 8px; }
  .stat-card { gap: 7px; min-width: 0; padding: 9px 8px; }
  .stat-icon { width: 27px; height: 27px; }
  .stat-card strong { font-size: 15px; }
  .stat-card div > span { font-size: 9px; }
  .link-grid, .compact-grid { grid-template-columns: 1fr; }
  .link-card { min-height: 139px; padding: 13px 14px 11px; }
  .card-description { margin: 10px 0 8px; }
  .section-heading h2 { font-size: 15px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .modal { padding: 20px; }
  .footer-note { font-size: 9px; }
}
