.desktop-shell {
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  min-height: 100%;
  height: 100%;
  width: 100%;
  background: var(--shell-bg);
}

.app-shell {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--window-bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.window-body {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.surface-scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(0, 0, 0, 0.42);
}

.panel-scrim {
  z-index: 3;
}

.sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 256px;
  padding: 6px 6px 10px;
  background: var(--window-bg-alt);
  border-right: 1px solid var(--border-subtle);
  transform: translateX(-100%);
  transition: transform 180ms cubic-bezier(0.2, 0, 0, 1);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app-shell.nav-open .sidebar {
  transform: translateX(0);
}

.meta-label,
.tab-button,
.side-empty,
.helper-text,
.form-hint,
.legend-pill,
.subtitle {
  color: var(--text-soft);
}

.sidebar-nav {
  display: grid;
  gap: 10px;
  padding-top: 42px;
  overflow: auto;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-label {
  padding: 0 12px;
  color: var(--text-faint);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav-group-items {
  display: grid;
  gap: 2px;
}

.nav-button {
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-button:hover,
.nav-button:focus-visible,
.tab-button:hover,
.tab-button:focus-visible,
.chip-button:hover,
.chip-button:focus-visible,
.memory-action:hover,
.memory-action:focus-visible,
.aux-button:hover,
.aux-button:focus-visible,
.graph-button:hover,
.graph-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible,
.memory-toolbar button:hover,
.memory-toolbar button:focus-visible {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-button.active,
.tab-button.active,
.chip-button.active,
.base-button.active,
.angle-toggle.active,
.history-toggle.active {
  background: var(--surface-active);
  color: var(--text);
}

.nav-footer {
  margin-top: auto;
  padding-top: 4px;
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 10px 14px 4px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
}

.mode-title-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.mode-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
}

.mode-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  color: var(--text-soft);
}

.mode-caption {
  display: none;
}

.topbar-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.chip-button,
.base-button,
.angle-toggle,
.aux-button,
.graph-button {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--text-soft);
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 0;
  flex: 1;
  min-height: 0;
}

.app-shell.layout-desktop .workspace.with-side-panel {
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: 0;
}

.panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.main-panel {
  padding: 0 4px 4px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.main-panel > * {
  min-height: 100%;
}

.side-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #1d1f25;
  border-left: 1px solid var(--border-subtle);
  border-radius: 0;
  overflow: hidden;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem 0;
}

.side-panel-title {
  color: var(--text-soft);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.side-panel-close {
  width: 30px;
  height: 30px;
}

.side-tabs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem 1rem;
}

.tab-button {
  flex: 1;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.side-body {
  padding: 0 1rem 1rem;
  min-height: 0;
  overflow: auto;
}

.app-shell.layout-desktop .side-panel {
  background: #1d1f25;
  border-left: 1px solid var(--border-faint);
}

.app-shell.layout-desktop .side-panel-header {
  display: none;
}

.app-shell.layout-desktop .side-tabs {
  gap: 1.35rem;
  flex-wrap: nowrap;
  padding: 0.9rem 1rem 0.2rem;
}

.app-shell.layout-desktop .tab-button {
  flex: 0 0 auto;
  padding: 0 0 0.7rem;
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

.app-shell.layout-desktop .tab-button.active {
  background: transparent;
  box-shadow: inset 0 -3px 0 var(--accent);
}

.icon-button svg,
.nav-icon svg,
.mode-glyph svg,
.calc-button svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
  flex: 0 0 auto;
}

.calc-button svg {
  margin: 0 auto;
}

.app-shell.layout-desktop .side-body {
  padding: 0.15rem 0.95rem 0.75rem;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header h3,
.form-section h3 {
  margin: 0;
  font-size: 1.1rem;
}

.form-section {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0.35rem 0.5rem 0.5rem;
  gap: 1rem;
}

.app-shell.layout-tablet .side-panel,
.app-shell.layout-mobile .side-panel {
  width: min(100%, 360px);
}

.label-stack {
  display: grid;
  gap: 0.45rem;
}
