:root {
  --workspace-sidebar: #091e36;
  --workspace-side-text: #d0e1f0;
  --workspace-side-muted: #9bb9d4;
  --workspace-side-width: 264px;
}

:root[data-theme="light"] .workspace,
:root[data-theme="brand"] .workspace {
  --c-bg: #edf3f9;
  --c-title: #122c48;
  --c-text: #385677;
  --c-muted: #58718c;
  --c-line: #dae6f2;
  --c-accent: #125f9f;
  --c-accent-2: #1978cd;
  --c-hover: #edf5fd;
  --c-shadow: 0 12px 40px rgb(19 61 108 / 8%);
  background: radial-gradient(ellipse at 98% 0%, #dcecf9, transparent 65%), var(--c-bg);
}

.workspace {
  display: grid;
  grid-template: 75px minmax(0, 1fr) / var(--workspace-side-width) minmax(0, 1fr);
  font: 14px/1.55 Inter, "Segoe UI", system-ui, sans-serif;
  zoom: 1;
  height: 100vh;
  height: 100dvh;
}

.workspace.signed-out .shell, .workspace.signed-out .topbar { visibility: hidden; }
.workspace .shell { display: contents; }
.workspace .topbar {
  grid-area: 1 / 2;
  height: auto;
  background: var(--c-card);
  padding: 0 38px;
  border-bottom: 1px solid var(--c-line);
  box-shadow: 0 4px 18px rgb(17 65 105 / 5%);
}
.workspace-crumb { color: var(--c-muted); font-size: 13px; }
.workspace-crumb span { margin: 0 6px; }
.workspace-crumb b { color: var(--c-title); }
.workspace .side {
  grid-area: 1 / 1 / -1 / 2;
  min-height: 0;
  overflow-y: auto;
  width: auto;
  padding: 0 13px 13px;
  background: radial-gradient(ellipse at 90% 0%, #174e7c 0%, transparent 36%),
    linear-gradient(175deg, #0b2b4c 0%, var(--workspace-sidebar) 72%, #07182c 100%);
  border: 0;
  box-shadow: 10px 0 55px rgb(8 34 64 / 10%);
  z-index: 5;
}
.workspace-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 112px;
  margin: 0 -13px 21px;
  padding: 0 25px;
  border-bottom: 1px solid #ffffff1c;
  color: white;
  text-decoration: none;
}
.workspace-brand img.kvart-mark {
  width: 48px;
  height: 48px;
  padding: 4px;
  border-radius: 10px;
  background: white;
  box-shadow: 0 0 20px #45a9e73a;
}
.workspace-brand strong { display: block; color: white; font-size: 22px; line-height: 1.2; letter-spacing: 4px; }
.workspace-brand small { color: var(--workspace-side-muted); font-size: 11px; letter-spacing: 1.5px; }
.workspace .side .nav-pill { color: var(--workspace-side-text); font-size: 13px; font-weight: 650; text-decoration: none; }
.workspace .side .nav-pill:hover { background: #ffffff17; color: white; }
.workspace .side .nav-pill.primary, .workspace .side .nav-pill.primary:hover {
  background: linear-gradient(105deg, #1766ad, #267dd0);
  color: white;
  box-shadow: 0 8px 20px #031a3080;
}
.workspace .side #open-library { background: transparent; color: var(--workspace-side-text); }
.workspace .side #open-library:hover { background: #ffffff17; }
.workspace .aside-logo { margin: 12px 0 0; width: 100%; padding: 13px; border-top: 1px solid #ffffff1c; border-radius: 0; }
.workspace .aside-logo img { height: 42px; margin: 0 auto; }
.workspace .aside-logo:hover { background: #ffffff0a; }
.workspace .content { grid-area: 2 / 2; min-height: 0; padding: 34px 42px 38px; gap: 24px; overflow: auto; }
.workspace #work, .workspace #hints { border-radius: 14px; }
.workspace h1 { color: var(--c-title); font-size: 30px; letter-spacing: -.045em; line-height: 1.2; }
.workspace .act { border-radius: 8px; }
.workspace .act.primary { background: linear-gradient(105deg, #1263ac, #1978cd); color: white; }
.sidebar-history {
  display: flex;
  flex: 1 0 92px;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #ffffff1c;
}
.history-toolbar, .history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.history-toolbar h2 { margin: 0; padding-left: 4px; font-size: 13px; color: var(--workspace-side-text); }
.sidebar-history .act {
  height: 30px;
  padding: 0 8px;
  background: #ffffff0c;
  border-color: #ffffff28;
  color: var(--workspace-side-text);
  font-size: 12px;
}
.sidebar-history .act:hover:not(:disabled) { background: #ffffff22; color: white; }
.sidebar-history .search-box { margin: 0; }
.sidebar-history .search-box .bi { color: var(--workspace-side-muted); }
.sidebar-history #hist-search {
  background: #081b30;
  border-color: #ffffff32;
  color: white;
}
.sidebar-history #hist-search::placeholder { color: var(--workspace-side-muted); opacity: 1; }
.history-pagination { flex: none; color: var(--workspace-side-muted); font-size: 12px; }
.history-status { margin: 0; padding: 2px 4px; color: var(--workspace-side-muted); font-size: 12px; }
.history-status:empty { display: none; }
#history { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0; }
#history:empty { display: none; }
#history li + li { border-top: 1px solid #ffffff12; }
#history .hist-item { width: 100%; border-radius: 6px; padding: 8px 5px; }
#history .hist-item:hover, #history .hist-item[aria-current] { background: #ffffff1a; }
#history .hist-item:focus-visible { outline-color: #85baef; }
#history .prev { color: var(--workspace-side-text); }
#history .date { color: var(--workspace-side-muted); }
#history .counts .r { color: #ff9ca4; }
#history .counts .y { color: #ffd47d; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dialog-actions .act { white-space: nowrap; }
#menu-toggle { display: none; }

@media (max-width: 1140px) {
  .workspace { --workspace-side-width: 218px; }
  .workspace .topbar { padding-inline: 24px; }
  .workspace .content { padding: 26px 24px; }
}
@media (max-width: 820px) {
  .workspace { grid-template: 63px minmax(0, 1fr) / minmax(0, 1fr); }
  .workspace .topbar, .workspace .content { grid-column: 1; padding-inline: 14px; }
  .workspace .side { position: fixed; inset: 0 auto 0 0; display: none; width: 243px; }
  .workspace .side.open { display: flex; box-shadow: 0 0 0 999px #081f386e; z-index: 20; }
  .workspace .topbar:has(+ .shell .side.open) { position: relative; z-index: 21; }
  .workspace .topbar #menu-toggle { display: inline-flex; }
  .workspace h1 { font-size: 25px; }
}
@media (max-width: 465px) {
  .workspace .who-chip .who, .workspace #logout .tx, .workspace .bell-label { display: none; }
  .workspace .topbar button { padding-inline: 6px; }
  .workspace .who-chip { padding-right: 4px; }
  .workspace .topbar { gap: 6px; }
  .workspace-crumb { font-size: 11px; white-space: nowrap; }
  .workspace #theme-sel { width: 87px; }
}

.workspace-dialog {
  width: min(470px, calc(100% - 32px));
  padding: 23px;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: var(--c-card);
  color: var(--c-title);
  box-shadow: var(--c-shadow);
}
.workspace-dialog::backdrop { background: #081b308c; }
.workspace-dialog h2 { margin: 0 0 16px; font-size: 20px; }
.workspace-dialog p { color: var(--c-muted); }
.workspace-dialog input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid var(--c-line);
  border-radius: 8px;
  font: inherit;
  background: var(--c-card);
  color: var(--c-title);
}
.workspace-dialog .dialog-actions { margin-top: 20px; }

.desktop-install-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--install-border);
  border-radius: 11px;
  background: var(--install-bg);
  color: var(--install-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.desktop-install-button:hover {
  border-color: var(--install-hover-border);
  background: var(--install-hover);
}
.desktop-install-icon {
  box-sizing: content-box;
  flex: none;
  width: 18px;
  height: 18px;
  padding: 7px;
  border-radius: 7px;
  background: var(--install-icon-bg);
  color: var(--install-icon-ink);
}
.sidebar-install {
  --install-bg: #132f4b;
  --install-border: #315575;
  --install-ink: #f0f7ff;
  --install-icon-bg: #245681;
  --install-icon-ink: #e1f1ff;
  --install-hover: #1c4265;
  --install-hover-border: #71a7d5;
  flex: none;
  margin-top: 8px;
}
.login-install {
  --install-bg: var(--c-tint-soft);
  --install-border: var(--c-tint-line);
  --install-ink: var(--c-title);
  --install-icon-bg: var(--c-tint);
  --install-icon-ink: var(--c-accent);
  --install-hover: var(--c-tint);
  --install-hover-border: var(--c-accent);
  justify-content: center;
  margin-top: 6px;
}
.desktop-platforms { display: flex; gap: 8px; flex-wrap: wrap; }
.desktop-setup-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  background: linear-gradient(105deg, #1263ac, #1978cd);
  color: white;
  font-weight: 650;
  text-decoration: none;
}
.desktop-setup-link:hover { filter: brightness(1.09); }
#desktop-install .desktop-install-error { color: var(--c-red); }
.desktop-update {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 12px;
  border: 1px solid var(--c-line);
  border-radius: 12px;
  background: var(--c-card);
  color: var(--c-title);
  box-shadow: var(--c-shadow);
}
.desktop-update small { display: block; color: var(--c-muted); }
.desktop-download-notice {
  position: fixed;
  z-index: 13;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100% - 32px));
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
  background: var(--c-card);
  color: var(--c-title);
  box-shadow: var(--c-shadow);
  overflow-wrap: anywhere;
}
.desktop-update:not([hidden]) + .desktop-download-notice { bottom: auto; top: 16px; }
.desktop-update-dismiss {
  border: 0;
  background: transparent;
  color: var(--c-muted);
  font-size: 20px;
  cursor: pointer;
}
@media (max-width: 420px) {
  .desktop-update { flex-wrap: wrap; }
}

:root[data-theme="light"] .workspace-secondary,
:root[data-theme="brand"] .workspace-secondary {
  --c-bg: #edf3f9;
  --c-title: #122c48;
  --c-text: #385677;
  --c-muted: #58718c;
  --c-line: #dae6f2;
  --c-accent: #125f9f;
  background: radial-gradient(ellipse at 98% 0%, #dcecf9, transparent 65%), #edf3f9;
}
.workspace-secondary { font-family: Inter, "Segoe UI", system-ui, sans-serif; }
:root[data-theme="light"] .workspace-secondary > header,
:root[data-theme="brand"] .workspace-secondary > header {
  background: linear-gradient(105deg, #0b2b4c, #174e7c);
  color: white;
  min-height: 65px;
}
:root[data-theme="light"] .workspace-secondary > header .logo *,
:root[data-theme="brand"] .workspace-secondary > header .logo *,
:root[data-theme="light"] .workspace-secondary > header .who,
:root[data-theme="brand"] .workspace-secondary > header .who { color: #f1f7fd; }
:root[data-theme="light"] .workspace-secondary > header :is(button, select, .topbar-btn),
:root[data-theme="brand"] .workspace-secondary > header :is(button, select, .topbar-btn) {
  border-color: #ffffff45;
  background: #123957;
  color: white;
}
.workspace-secondary main h1 { font-size: 28px; letter-spacing: -.04em; }
