:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --rail: #080a0f;
  --panel: #121721;
  --panel-2: #1b2230;
  --panel-3: #222a39;
  --text: #eef3f8;
  --muted: #96a1ad;
  --accent: #8bffcf;
  --accent-2: #4cc9f0;
  --border: rgba(255, 255, 255, 0.09);
  --danger: #ff7777;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at top left, #172235 0, var(--bg) 42%); color: var(--text); min-height: 100vh; overflow: hidden; }
.hidden { display: none !important; }
button, input { font: inherit; }
button { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 0.58rem 0.85rem; cursor: pointer; transition: 0.16s ease; }
button:hover { border-color: rgba(139, 255, 207, 0.55); transform: translateY(-1px); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #071014; font-weight: 850; }
button.danger { color: var(--danger); }
button.subtle { background: transparent; }
button.icon { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 10px; }
input { width: 100%; border: 1px solid var(--border); background: rgba(255,255,255,0.045); color: var(--text); border-radius: 12px; padding: 0.65rem 0.75rem; outline: none; }
input:focus { border-color: rgba(139, 255, 207, 0.55); }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 3.2vw, 2.8rem); letter-spacing: -0.05em; }
h2 { font-size: 1.05rem; letter-spacing: -0.02em; }

.shell { display: grid; grid-template-columns: 68px 245px minmax(0, 1fr) 365px; height: 100vh; min-height: 100vh; }
.org-rail { background: rgba(8,10,15,0.96); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 0.85rem 0.55rem; }
.rail-logo, .org-dot, .rail-add { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font-weight: 900; padding: 0; }
.rail-logo { background: var(--accent); color: #06100e; font-size: 1.25rem; margin-bottom: 0.35rem; }
.org-buttons { display: grid; gap: 0.7rem; width: 100%; justify-items: center; overflow-y: auto; padding-bottom: 0.5rem; }
.org-dot { background: #202736; color: var(--text); border-color: transparent; letter-spacing: -0.03em; }
.org-dot.active { background: #eef3f8; color: #0b0d12; box-shadow: 0 0 0 4px rgba(139,255,207,0.12); }
.rail-add { margin-top: auto; background: transparent; border-style: dashed; color: var(--muted); }

.space-sidebar { background: rgba(14,17,24,0.92); border-right: 1px solid var(--border); padding: 1rem; overflow-y: auto; }
.sidebar-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.7rem; margin-bottom: 1rem; }
.eyebrow { color: var(--accent); font-weight: 900; text-transform: uppercase; letter-spacing: 0.15em; font-size: 0.68rem; margin-bottom: 0.32rem; }
.space-actions { display: flex; margin-bottom: 0.8rem; }
.space-actions button { width: 100%; }
.space-list { display: grid; gap: 0.48rem; }
.space-row { border-radius: 14px; display: grid; gap: 0.22rem; text-align: left; justify-items: start; width: 100%; background: transparent; padding: 0.75rem; }
.space-row span { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-row small { color: var(--muted); }
.space-row.active { background: rgba(139,255,207,0.12); border-color: rgba(139,255,207,0.45); }

.workspace { padding: 1.35rem; min-width: 0; overflow-y: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.65rem; justify-content: flex-end; }
.collections { display: grid; grid-template-columns: repeat(auto-fill, minmax(295px, 1fr)); gap: 1rem; align-items: start; padding-bottom: 2rem; }
.collection { min-height: 245px; padding: 1rem; background: rgba(18, 23, 33, 0.88); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 20px 70px rgba(0,0,0,0.22); }
.collection.drag-over { outline: 2px solid var(--accent); background: rgba(139,255,207,0.09); }
.collection-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.9rem; }
.collection-title { display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; }
.collection-title h3 { cursor: text; font-size: 1.05rem; }
.collection-actions { display: flex; align-items: center; gap: 0.4rem; }
.muted, .hint { color: var(--muted); font-size: 0.86rem; }
.item-list { display: grid; gap: 0.62rem; min-height: 105px; }
.empty-collection, .empty-state { color: var(--muted); border: 1px dashed var(--border); border-radius: 15px; padding: 1rem; }
.empty-collection { text-align: center; }
.empty-state { display: grid; gap: 0.25rem; margin-bottom: 0.8rem; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(440px, 100%); display: grid; gap: 0.85rem; padding: 1.4rem; background: rgba(18, 23, 33, 0.92); border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 24px 90px rgba(0,0,0,0.35); }
.auth-card h1 { font-size: clamp(2rem, 7vw, 3rem); }
.auth-logo { margin-bottom: 0.25rem; }
.auth-card button { width: 100%; }

.tabs-sidebar { background: rgba(9, 12, 18, 0.78); border-left: 1px solid var(--border); padding: 1rem; overflow-y: auto; backdrop-filter: blur(18px); }
.panel-heading, .tab-window-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-heading { margin-bottom: 0.35rem; }
.open-tab-windows { display: grid; gap: 1rem; margin-top: 1rem; }
.sync-panel { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); display: grid; gap: 0.65rem; }
.panel-heading.compact { margin-bottom: 0; }
.sync-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.tab-window { display: grid; gap: 0.55rem; }
.tab-window-header { color: var(--text); font-size: 0.88rem; }
.tab-window-header span { color: var(--muted); font-size: 0.78rem; }
.open-tabs { display: grid; gap: 0.55rem; }
.open-tab, .saved-item { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; gap: 0.62rem; align-items: center; padding: 0.62rem; border: 1px solid var(--border); border-radius: 14px; background: rgba(255,255,255,0.035); min-width: 0; }
.open-tab[draggable="true"], .saved-item[draggable="true"] { cursor: grab; }
.open-tab:active, .saved-item:active { cursor: grabbing; }
.saved-item { grid-template-columns: 25px minmax(0,1fr) 30px; }
.saved-item .remove { color: var(--danger); padding: 0.2rem 0.45rem; }
.favicon { width: 21px; height: 21px; border-radius: 6px; background: #293241; object-fit: contain; }
.item-text { min-width: 0; }
.title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 760; font-size: 0.9rem; }
.url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 0.76rem; margin-top: 0.12rem; }

@media (max-width: 1050px) {
  body { overflow: auto; }
  .shell { grid-template-columns: 60px minmax(185px, 230px) minmax(0, 1fr); height: auto; min-height: 100vh; }
  .tabs-sidebar { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: 56px minmax(0, 1fr); }
  .workspace { grid-column: 1 / -1; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .space-sidebar { min-height: 260px; }
  .actions { justify-content: flex-start; }
}
