/* Shared app chrome and controls. Landing/auth retain their own composition. */
:root {
  --control-height: 44px;
  --control-small: 38px;
  --app-gutter: clamp(20px, 2.2vw, 36px);
}

.app { grid-template-columns: var(--sb) minmax(0, 1fr); }
.app .content { padding: 28px var(--app-gutter) 48px; gap: 24px; }
.app .content > *, .studio-grid > *, .set-grid > * { min-width: 0; }
.app .topbar { min-height: 76px; padding: 14px var(--app-gutter); gap: 20px; }
.topbar .topbar-page-title { flex: 0 1 auto; min-width: 0; font-size: 18px; line-height: 1.3; }
.topbar .global-search { position: relative; left: auto; transform: none; width: auto; flex: 0 1 340px; margin-left: auto; }
.topbar .top-right { flex: none; margin-left: auto; gap: 10px; }
.app .sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.app .nav-item { min-height: 46px; flex-shrink: 0; }
.app .nav-item.active { box-shadow: inset 0 0 0 1px rgba(var(--pink-rgb), .12); }
.app .upgrade-card { background: linear-gradient(135deg, rgba(var(--pink-rgb), .14), rgba(var(--cyan-rgb), .04)); border: 1px solid rgba(var(--pink-rgb), .23); color: var(--text); }
.app .upgrade-card .btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); box-shadow: none; }

/* Identical dimensions for link, button and input controls. */
.workspace-ui .btn { min-height: var(--control-height); padding: 10px 16px; font-size: 14px; line-height: 20px; border: 1px solid transparent; gap: 8px; }
.workspace-ui .btn-sm { min-height: var(--control-small); padding: 8px 12px; font-size: 13px; line-height: 20px; }
.workspace-ui .btn-ghost { border-color: var(--border); }
.workspace-ui .btn-primary { box-shadow: 0 4px 16px rgba(var(--pink-rgb), .2); }
.workspace-ui .btn svg { flex-shrink: 0; }
.workspace-ui .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.workspace-ui :is(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.app :is(.icon-btn, .hamburger) { width: 44px; height: 44px; flex-shrink: 0; }
.app .field { margin-bottom: 20px; }
.app .field label { font-size: 13px; font-weight: 600; line-height: 1.5; }
.app .field :is(input, select), .app .form-control, .app .form-select { min-height: var(--control-height); font-size: 15px; }
.app .chip { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1.4; }
.app .inline-filter-search { height: var(--control-height); }
.app .inline-filter-search input { font-size: 14px; }
.app .content :is(.studio-note, .field-note, .pipeline-insight, .sub, .text-xs) { font-size: 13px; line-height: 1.55; }
.app .content .text-sm { font-size: 14px; }
.app .content :is(.card > h3, .output-head h3) { font-size: 18px; line-height: 1.4; }
.app .content :is(.studio-eyebrow, .dashboard-kicker) { font-size: 11px; letter-spacing: .06em; }
.app .content :is(.pipeline-metrics strong, .stat-val, .h-val) { font-variant-numeric: tabular-nums; }
.app .page-tabs, .app .analytics-tabs { gap: 4px; margin-bottom: 0; }
.app .page-tab, .app .analytics-tab { min-height: 44px; padding: 11px 16px; font-size: 14px; line-height: 20px; }

.ring { position: relative; isolation: isolate; }
.ring::after { z-index: 0; }
.ring b { z-index: 1; }

.dashboard-heading { min-height: 54px; gap: 16px; }
.dashboard-greet-title { font-size: clamp(20px, 2vw, 26px); line-height: 1.3; }
.app .dashboard-focus-card h2 { font-size: 21px; line-height: 1.4; }
.app .dashboard-focus-card p { font-size: 14px; max-width: 56ch; }
.app .dashboard-pipeline-card h2 { font-size: 18px; }
.app .dashboard-analysis-warning { padding: 14px 16px; border-radius: 12px; }
.app .pipeline-metrics > div { padding: 18px 12px; }
.app .pipeline-metrics strong { font-size: 28px; }
.app .pipeline-metrics span { font-size: 12px; line-height: 1.5; }
.app .checklist-card { margin-bottom: 0; }
.app .checklist-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* The toolbar stays below the sticky header and mobile navigation. */
.ideas-tools-row { z-index: 10; min-height: 44px; margin: 0; }
.ideas-filter-toggle { display: inline-flex; gap: 8px; width: auto; height: 44px; padding: 0 14px; color: var(--text); font-size: 14px; font-weight: 600; }
.ideas-filter-close { width: 36px; height: 36px; }
.ideas-tools-main { gap: 10px; }
.ideas-tools-main .inline-filter-search { width: clamp(180px, 24vw, 320px); }
.ideas-generate-action { display: grid; justify-items: center; gap: 3px; }
.ideas-generate-cost { color: var(--muted); font-size: 10px; line-height: 1.2; white-space: nowrap; }
.ideas-filter-field .form-select { height: 44px; }
.ideas-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); align-items: stretch; }
.idea-card { padding: 20px; gap: 12px; border-radius: 14px; background: var(--panel); }
.idea-card .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 600; }
.idea-card h4 { font-size: 17px; line-height: 1.45; }
.app .idea-card > p { font-size: 14px; line-height: 1.6; }
.idea-foot { flex-wrap: wrap; gap: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.idea-foot-actions { width: 100%; margin-left: 0; justify-content: space-between; gap: 10px; }
.idea-feedback-btn { width: 38px; height: 38px; border-color: var(--border); }
.idea-detail-panel h2 { line-height: 1.4; }

.studio-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: start; gap: 24px; }
.studio-grid > .card { padding: 24px; }
.studio-grid > .card > .studio-note { margin: 6px 0 20px; }
.studio-preset-strip-shell { position: relative; min-width: 0; margin: 14px 0 20px; }
.studio-presets.studio-preset-strip { display: flex; flex-wrap: nowrap; gap: 8px; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; padding: 2px 0 8px; touch-action: pan-x; }
.studio-presets.studio-preset-strip::-webkit-scrollbar { display: none; }
.studio-preset-strip .chip { flex: 0 0 auto; max-width: min(260px, 70vw); overflow: hidden; text-overflow: ellipsis; text-align: left; white-space: nowrap; scroll-snap-align: start; }
.studio-preset-strip-shell.has-overflow::before, .studio-preset-strip-shell.has-overflow:not(.is-at-end)::after { content: ""; position: absolute; z-index: 1; top: 0; bottom: 7px; width: 28px; pointer-events: none; }
.studio-preset-strip-shell.has-overflow::before { left: 0; opacity: 0; background: linear-gradient(90deg, var(--panel), transparent); transition: opacity .18s ease; }
.studio-preset-strip-shell.has-overflow.is-scrolled::before { opacity: 1; }
.studio-preset-strip-shell.has-overflow:not(.is-at-end)::after { right: 0; background: linear-gradient(270deg, var(--panel), transparent); }
.studio-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
.studio-actions .btn-primary { grid-column: 1 / -1; }
.output-head { align-items: center; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.output-head > .row { flex-shrink: 0; }
.studio-empty { min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.app .studio-empty-note { font-size: 14px; margin: 0; }
.studio-outline { justify-content: center; }
.app .studio-production :is(small, .studio-production-notes) { font-size: 12px; line-height: 1.5; }
.app .studio-production :is(b, .studio-shot p) { font-size: 14px; line-height: 1.5; }
.set-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 24px; }
.set-grid > .card { padding: 24px; }
.set-grid .settings-ref-row { align-items: stretch; }
.set-grid .settings-ref-row .form-control { min-width: 0; }
.app .analytics-entity-form .btn { height: auto; }
.app .analytics-range button { min-height: 36px; font-size: 12px; }
.app .analytics-indicator-toggle { min-height: 38px; font-size: 13px; }
.session-unavailable > .content { display: none; }
.session-retry { margin: 28px var(--app-gutter); display: grid; justify-items: start; gap: 16px; }
.session-retry h2 { font-size: 20px; }
.session-retry p { color: var(--muted); font-size: 14px; line-height: 1.6; }

@media (max-width: 1200px) {
  .topbar .global-search { display: none; }
  .topbar .global-search.is-mobile-open { display: flex; position: absolute; left: 50%; right: auto; top: calc(100% + 8px); width: min(620px, calc(100% - 24px)); margin: 0; transform: translateX(-50%); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  body.nav-open { overflow: hidden; }
  .app .sidebar { width: min(290px, calc(100vw - 56px)); }
  .app .topbar { gap: 12px; }
  .studio-grid, .set-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .app .content { padding: 20px 16px 32px; gap: 20px; }
  .app .topbar { min-height: 72px; padding: 12px 16px; gap: 10px; }
  .topbar .topbar-page-title { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .top-right { gap: 6px; }
  .topbar .energy-pill { display: none; }
  .workspace-ui .btn-sm, .app .chip, .idea-feedback-btn { min-height: 44px; }
  .idea-feedback-btn { width: 44px; }
  .app .field :is(input, select), .app .form-control, .app .form-select, .app .inline-filter-search input { font-size: 16px; }
  .dashboard-heading > .row { width: 100%; justify-content: space-between; }
  .app .checklist-list { grid-template-columns: minmax(0, 1fr); }
  .ideas-tools-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .ideas-filter-anchor { justify-self: stretch; }
  .ideas-filter-toggle { width: 100%; justify-content: center; }
  .ideas-tools-main { display: contents; }
  .ideas-tools-main .inline-filter-search { grid-column: 2; grid-row: 1; width: 100%; min-width: 0; }
  .ideas-tools-main > .btn { width: 100%; }
  .ideas-generate-action { grid-column: 2; grid-row: 2; width: 100%; }
  .ideas-generate-action > .btn { width: 100%; }
  .ideas-grid { grid-template-columns: minmax(0, 1fr); }
  .idea-card { padding: 18px; }
  .studio-grid > .card, .set-grid > .card { padding: 18px; }
  .studio-empty { min-height: 240px; }
  .app .analytics-tab, .app .page-tab { padding: 10px 8px; font-size: 13px; }
  .app .analytics-range button { min-height: 44px; }
  .app .analytics-chart-controls { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .app *, .app *::before, .app *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Material quality: keep each palette, give chrome and content distinct depth. */
:root {
  --material-edge: color-mix(in srgb, var(--text) 12%, var(--border));
  --material-shadow: 0 2px 3px rgb(0 0 0 / .03), 0 12px 32px rgb(0 0 0 / .09);
  --material-float: 0 24px 80px rgb(0 0 0 / .35), inset 0 1px 0 color-mix(in srgb, var(--text) 7%, transparent);
}
.workspace-ui .app .card {
  border-color: var(--material-edge);
  background: var(--panel);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: var(--material-shadow), inset 0 1px 0 color-mix(in srgb, var(--text) 3%, transparent);
}
.workspace-ui .app .sidebar {
  background: var(--bg-2);
  background: color-mix(in srgb, var(--bg-2) 94%, transparent);
  border-color: var(--material-edge);
}
.workspace-ui .app .topbar {
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-color: var(--material-edge);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.workspace-ui .app :is(.card h2,.card h3,.topbar-page-title) { text-wrap: balance; }
.workspace-ui .app .card p { text-wrap: pretty; }
.workspace-ui :is(.btn,.icon-btn,.rk-dialog-close) { transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease; }
.workspace-ui :is(.btn-ghost,.rk-dialog-close):hover { background: var(--panel-2); border-color: var(--muted-2); }
.workspace-ui:has(dialog[open]) { overflow: hidden; }
@media (prefers-reduced-transparency: reduce) {
  .workspace-ui .app .card { background: var(--panel); }
  .workspace-ui .app .sidebar { background: var(--bg-2); }
  .workspace-ui .app .topbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .workspace-ui .app .card, .workspace-ui .rk-dialog { border-color: var(--muted); background: var(--panel); }
  .workspace-ui .app .topbar { background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  .workspace-ui :is(.btn,.icon-btn,.rk-dialog-close) { transition: none; }
}


/* Sidebar wordmark: clear brand hierarchy and an intentional compact lockup. */
.workspace-ui .sidebar .brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 9px 10px 18px;
  margin: 0 0 8px;
  border-bottom: 1px solid var(--material-edge, var(--border));
  text-decoration: none;
}
.workspace-ui .sidebar .brand-lockup > img { display: block; width: 38px; height: 38px; flex: none; object-fit: contain; }
.workspace-ui .sidebar .brand-copy { display: grid; gap: 3px; min-width: 0; }
.workspace-ui .sidebar .brand-lockup b { font-size: 20px; line-height: 1.1; letter-spacing: -.04em; }
.workspace-ui .sidebar .brand-copy small { color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1.3; letter-spacing: .09em; text-transform: uppercase; }
.workspace-ui .sidebar .brand-lockup:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 8px; }
@media (max-width: 600px) { .workspace-ui .sidebar .brand-lockup { min-height: 68px; } }
