:root {
  color-scheme: dark;
  --bg: #080a10;
  --surface: rgba(20, 23, 34, 0.82);
  --surface-solid: #141722;
  --surface-hover: #1b1f2d;
  --border: rgba(255, 255, 255, 0.085);
  --text: #f6f7fb;
  --muted: #9298aa;
  --accent: #7c5cff;
  --accent-2: #37c8ff;
  --success: #42d69b;
  --warning: #f7b955;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f9;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #fff;
  --surface-hover: #f5f6fb;
  --border: rgba(20, 25, 45, 0.09);
  --text: #121522;
  --muted: #6c7283;
  --shadow: 0 20px 55px rgba(35, 40, 65, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, sans-serif; overflow-x: hidden; transition: background .25s, color .25s; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.ambient { position: fixed; width: 460px; height: 460px; border-radius: 50%; filter: blur(120px); opacity: .12; pointer-events: none; }
.ambient-one { left: -170px; top: -170px; background: #6c4cff; }
.ambient-two { right: -200px; bottom: -180px; background: #00c2ff; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px 22px; border-right: 1px solid var(--border); background: rgba(9, 11, 18, .72); backdrop-filter: blur(20px); display: flex; flex-direction: column; z-index: 20; }
:root[data-theme="light"] .sidebar { background: rgba(245, 247, 251, .8); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; padding: 0 8px 30px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: white; font-family: Manrope; font-weight: 800; background: linear-gradient(145deg, var(--accent), #5234d9); box-shadow: 0 8px 28px rgba(124, 92, 255, .32); }
.brand-copy { display: flex; align-items: baseline; gap: 5px; font-family: Manrope; letter-spacing: -.03em; }
.brand-copy strong { font-size: 20px; }
.brand-copy small { color: var(--accent-2); font-weight: 800; }
.nav-list { display: grid; gap: 7px; }
.nav-item { width: 100%; padding: 12px 14px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); text-align: left; font-weight: 600; cursor: pointer; transition: .18s; }
.nav-item span { display: inline-grid; width: 26px; place-items: center; font-size: 17px; }
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active { color: #fff; background: linear-gradient(100deg, rgba(124,92,255,.85), rgba(124,92,255,.45)); box-shadow: 0 10px 28px rgba(85, 58, 196, .18); }
.sidebar-footer { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 15px 13px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer strong { font-size: 12px; }
.sidebar-footer small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(66,214,155,.1); }

main { min-width: 0; padding: 0 36px; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; border-bottom: 1px solid var(--border); }
.mobile-brand { display: none; align-items: center; gap: 10px; font-family: Manrope; }
.search-box { width: min(460px, 45vw); height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--muted); }
.search-box:focus-within { border-color: rgba(124,92,255,.6); box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
.search-box input { min-width: 0; flex: 1; color: var(--text); background: transparent; border: 0; outline: 0; }
.search-box input::placeholder { color: var(--muted); }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; padding: 3px 7px; border-radius: 6px; font-size: 10px; color: var(--muted); background: var(--surface-hover); }
.icon-button, .close-button { border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.icon-button { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.primary-button, .secondary-button { min-height: 44px; border-radius: 12px; padding: 0 17px; font-weight: 700; cursor: pointer; border: 1px solid transparent; }
.primary-button { color: #fff; background: linear-gradient(135deg, var(--accent), #6846ec); box-shadow: 0 9px 25px rgba(124,92,255,.24); }
.primary-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.secondary-button { border-color: var(--border); background: var(--surface); }

.hero { max-width: 1540px; margin: 0 auto; padding: 46px 0 34px; display: flex; justify-content: space-between; gap: 28px; align-items: flex-end; }
.eyebrow, .section-kicker { margin: 0 0 8px; color: var(--accent-2); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.hero h1 { margin: 0; font-family: Manrope; font-size: clamp(31px, 4vw, 46px); line-height: 1.08; letter-spacing: -.045em; }
.hero h1 span { font-size: .78em; }
.hero > div > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 15px; }
.hero-stats { display: flex; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.hero-stats div { min-width: 104px; padding: 14px 18px; text-align: center; }
.hero-stats div + div { border-left: 1px solid var(--border); }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { font: 800 20px Manrope; }
.hero-stats span { margin-top: 2px; color: var(--muted); font-size: 10px; }

.workspace-grid { max-width: 1540px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; align-items: start; }
.apps-panel, .panel { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.apps-panel { padding: 24px; }
.section-heading, .panel-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.section-heading h2, .panel h2 { margin: 0; font: 700 20px Manrope; letter-spacing: -.03em; }
.category-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.pill { padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; cursor: pointer; }
.pill.active, .pill:hover { color: var(--text); border-color: rgba(124,92,255,.4); background: rgba(124,92,255,.12); }
.app-grid { margin-top: 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.app-card { min-height: 218px; padding: 17px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 15px; background: linear-gradient(145deg, rgba(255,255,255,.035), rgba(255,255,255,.012)); transition: transform .2s, border-color .2s, background .2s; }
.app-card:hover { transform: translateY(-3px); border-color: rgba(124,92,255,.32); background: linear-gradient(145deg, rgba(124,92,255,.08), rgba(255,255,255,.02)); }
.card-top, .card-footer { display: flex; align-items: center; justify-content: space-between; }
.app-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; font-size: 19px; background: linear-gradient(145deg, rgba(124,92,255,.22), rgba(55,200,255,.08)); border: 1px solid rgba(124,92,255,.18); }
.favorite-button { border: 0; background: transparent; color: var(--muted); font-size: 22px; cursor: pointer; transition: .15s; }
.favorite-button:hover, .favorite-button.active { color: #ffd66b; transform: scale(1.08); }
.card-copy { margin: 16px 0; }
.app-category { color: var(--accent-2); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.card-copy h3 { margin: 5px 0 6px; font: 700 15px Manrope; line-height: 1.25; }
.card-copy p { margin: 0; min-height: 38px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.card-footer { margin-top: auto; }
.status-badge { padding: 5px 8px; border-radius: 7px; color: var(--success); background: rgba(66,214,155,.1); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.status-badge.project { color: var(--warning); background: rgba(247,185,85,.1); }
.open-app { padding: 6px 0; border: 0; background: transparent; color: var(--text); font-size: 10px; font-weight: 700; cursor: pointer; }
.open-app:disabled { color: var(--muted); cursor: not-allowed; }
.open-app span { margin-left: 3px; color: var(--accent-2); }
.empty-state { padding: 60px 20px 45px; text-align: center; color: var(--muted); }
.empty-state > span { font-size: 32px; }
.empty-state h3 { color: var(--text); margin: 12px 0 5px; }
.empty-state p { margin: 0; font-size: 12px; }

.right-column { display: grid; gap: 18px; }
.panel { padding: 20px; }
.panel-heading #savedStatus { color: var(--success); font-size: 9px; opacity: 0; transition: opacity .2s; }
.panel-heading #savedStatus.visible { opacity: 1; }
.quick-notes textarea { width: 100%; height: 156px; resize: vertical; margin-top: 17px; padding: 13px; color: var(--text); border: 1px solid var(--border); border-radius: 11px; background: rgba(0,0,0,.12); outline: 0; line-height: 1.55; font-size: 12px; }
.quick-notes textarea:focus { border-color: rgba(124,92,255,.48); }
.note-footer { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 9px; }
.note-footer button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 9px; }
.note-footer button:hover { color: #ff8585; }
.recent-hint { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.recent-list { display: grid; gap: 8px; margin-top: 16px; }
.recent-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; text-align: left; border: 1px solid var(--border); border-radius: 11px; background: rgba(255,255,255,.025); cursor: pointer; transition: .18s; }
.recent-item:hover { border-color: rgba(124,92,255,.35); background: rgba(124,92,255,.07); transform: translateX(2px); }
.recent-icon { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 31px; border-radius: 9px; background: rgba(124,92,255,.12); font-size: 14px; }
.recent-copy { min-width: 0; flex: 1; }
.recent-copy strong, .recent-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-copy strong { font-size: 9px; }
.recent-copy small { margin-top: 3px; color: var(--muted); font-size: 7px; text-transform: uppercase; letter-spacing: .06em; }
.recent-arrow { color: var(--accent-2); font-size: 11px; }
.recent-empty { margin: 15px 0 0; padding: 15px 8px; color: var(--muted); font-size: 9px; line-height: 1.55; text-align: center; border: 1px dashed var(--border); border-radius: 11px; }
.backup-panel > p { margin: 9px 0 15px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.backup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.backup-button { min-height: 36px; display: grid; place-items: center; padding: 0 8px; border: 1px solid rgba(124,92,255,.28); border-radius: 9px; color: #fff; background: rgba(124,92,255,.17); font-size: 8px; font-weight: 800; cursor: pointer; }
.backup-button.secondary { border-color: var(--border); color: var(--text); background: rgba(255,255,255,.025); }
.backup-button:hover { filter: brightness(1.18); }
.backup-status { display: block; min-height: 13px; margin-top: 9px; color: var(--success); font-size: 8px; }
.backup-status.error { color: #ff8585; }
footer { max-width: 1540px; margin: 0 auto; padding: 25px 2px 28px; display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }

.mobile-nav { display: none; }
dialog { width: min(500px, calc(100% - 28px)); padding: 0; color: var(--text); border: 1px solid var(--border); border-radius: 18px; background: var(--surface-solid); box-shadow: 0 28px 90px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(3,4,8,.75); backdrop-filter: blur(5px); }
dialog form { padding: 24px; }
.modal-heading { display: flex; justify-content: space-between; margin-bottom: 22px; }
.modal-heading h2 { margin: 0; font: 700 21px Manrope; }
.close-button { width: 34px; height: 34px; border-radius: 10px; font-size: 20px; }
dialog label { display: grid; gap: 7px; margin: 13px 0; color: var(--muted); font-size: 10px; font-weight: 700; }
dialog input, dialog select { width: 100%; height: 43px; padding: 0 12px; color: var(--text); border: 1px solid var(--border); border-radius: 10px; background: var(--surface-hover); outline: 0; }
dialog input:focus, dialog select:focus { border-color: rgba(124,92,255,.55); }
.form-row { display: grid; grid-template-columns: 1fr 100px; gap: 12px; }
.form-help { margin: 7px 0 20px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; }

@media (max-width: 1160px) {
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  main { padding: 0 20px 88px; }
  .topbar { justify-content: space-between; gap: 8px; }
  .mobile-brand { display: flex; }
  .mobile-brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .mobile-brand strong { font-size: 12px; }
  .search-box { margin-left: auto; width: min(330px, 42vw); }
  .search-box kbd { display: none; }
  .primary-button#openAddModal { display: none; }
  .workspace-grid { grid-template-columns: 1fr; }
  .right-column { grid-template-columns: 1fr 1fr; }
  .mobile-nav { position: fixed; left: 12px; right: 12px; bottom: 10px; height: 66px; padding: 7px 13px; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; border: 1px solid var(--border); border-radius: 18px; background: rgba(16,19,28,.92); backdrop-filter: blur(20px); box-shadow: 0 12px 40px rgba(0,0,0,.4); }
  .mobile-nav-item { display: grid; place-items: center; gap: 3px; border: 0; background: transparent; color: var(--muted); }
  .mobile-nav-item span { font-size: 18px; }
  .mobile-nav-item small { font-size: 8px; }
  .mobile-nav-item.active { color: var(--accent-2); }
  .mobile-add { justify-self: center; width: 44px; height: 44px; margin-top: -27px; border: 0; border-radius: 14px; color: #fff; font-size: 24px; background: linear-gradient(135deg, var(--accent), #6742e8); box-shadow: 0 9px 28px rgba(124,92,255,.4); }
}

@media (max-width: 620px) {
  main { padding-inline: 13px; }
  .topbar { height: auto; padding: 14px 0; flex-wrap: wrap; }
  .mobile-brand { flex: 1; }
  .search-box { order: 3; width: 100%; }
  .hero { padding: 31px 2px 24px; display: block; }
  .hero-stats { width: 100%; margin-top: 22px; }
  .hero-stats div { flex: 1; min-width: 0; padding: 12px 8px; }
  .workspace-grid { gap: 13px; }
  .apps-panel { padding: 17px 13px; }
  .section-heading { display: block; }
  .category-pills { margin-top: 15px; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; }
  .pill { white-space: nowrap; }
  .app-grid { grid-template-columns: 1fr; gap: 10px; }
  .app-card { min-height: 198px; }
  .right-column { grid-template-columns: 1fr; }
  footer { padding-bottom: 10px; }
  .form-row { grid-template-columns: 1fr; }
  .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
