:root {
  --bg: #f9fafb;
  --bg-elevated: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.14);
  --danger: #dc2626;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --content-max: min(46rem, 100%);
  --landing-max: min(76rem, 100%);
  --hairline: rgba(15, 23, 42, 0.08);
  --surface-card: #ffffff;
  --surface-shade: #f1f5f9;
  --surface-inset: #f8fafc;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.1);
  --bubble-user-bg: #ecfdf5;
  --bubble-user-border: rgba(13, 148, 136, 0.35);
  --bubble-assistant-bg: #f8fafc;
  --bubble-assistant-border: #e2e8f0;
  --code-text: #334155;
}

html {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

@media (min-width: 900px) {
  html,
  body {
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
  }

  /* Idle landing often exceeds one viewport (hero + textarea + projects); allow scroll. */
  html:has(#workspace.workspace--idle),
  body:has(#workspace.workspace--idle) {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow-x: clip;
    overflow-y: auto;
  }

  .layout:has(#workspace.workspace--idle) {
    max-height: none;
    min-height: 100dvh;
    padding-top: clamp(1rem, 3dvh, 1.5rem);
    padding-bottom: clamp(1rem, 3dvh, 1.5rem);
  }

  html.app-landing-scroll .layout {
    max-height: none;
    min-height: 100dvh;
    padding-top: clamp(1rem, 3dvh, 1.5rem);
    padding-bottom: clamp(1rem, 3dvh, 1.5rem);
  }

  html.app-landing-scroll .workspace {
    flex: 1;
    min-height: 0;
  }
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(13, 148, 136, 0.06), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 5%, rgba(51, 65, 85, 0.04), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #eef1f5 42%, var(--bg) 100%);
  overflow-x: clip;
}

.layout {
  --layout-pad-x: clamp(1rem, 3vw, 1.75rem);
  max-width: min(1400px, 98vw);
  margin: 0 auto;
  padding: 1.1rem var(--layout-pad-x) 0.75rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

@media (min-width: 900px) {
  .layout {
    min-height: 100dvh;
    max-height: 100dvh;
  }
}

.workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0;
}

.workspace-loader {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(248, 250, 252, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.workspace-loader[hidden] {
  display: none !important;
}

.workspace-loader__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.75rem 2rem;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 16px 48px rgba(15, 23, 42, 0.1);
  min-width: min(18rem, 100%);
}

.workspace-loader__spinner {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 3px solid rgba(13, 148, 136, 0.18);
  border-top-color: var(--accent);
  animation: workspace-loader-spin 0.75s linear infinite;
}

.workspace-loader__text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  text-align: center;
  letter-spacing: 0.01em;
}

@keyframes workspace-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

.workspace--loading .composer-status {
  visibility: hidden;
}

@media (max-width: 899px) {
  .workspace {
    flex: 0 0 auto;
    min-height: auto;
  }

  .workspace--idle.workspace {
    flex: 1;
    min-height: 0;
  }

  .layout {
    min-height: 100%;
    max-height: none;
  }

  html.app-landing-scroll .layout {
    min-height: 100dvh;
    padding-top: clamp(1rem, 3dvh, 1.5rem);
    padding-bottom: clamp(1rem, 3dvh, 1.5rem);
  }
}

.workspace--active .workspace-landing {
  display: none !important;
}

.workspace--idle .main {
  display: none !important;
}

.workspace-landing {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  justify-content: safe center;
  text-align: center;
  padding: clamp(1rem, 3dvh, 1.5rem) 0;
  min-height: 0;
  width: 100%;
  max-width: var(--landing-max);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  gap: 1.5rem;
}

.workspace--idle .workspace-landing {
  display: flex;
}

.landing-hero.generate-card {
  padding: 2.25rem 1.75rem 2.35rem;
  border-radius: 22px;
  text-align: center;
}

.landing-hero.generate-card .composer-idle-anchor {
  width: 100%;
  margin-top: 1.5rem;
  text-align: left;
}

@media (max-height: 760px) {
  .landing-hero.generate-card {
    padding: 1.35rem 1.35rem 1.45rem;
  }

  .landing-hero.generate-card .composer-idle-anchor {
    margin-top: 1rem;
  }

  .landing-title {
    margin-bottom: 0.65rem;
  }

  .landing-kicker {
    margin-bottom: 0.65rem;
  }
}

.landing-title-accent {
  background: linear-gradient(105deg, #0f766e 0%, #0d9488 42%, #0891b2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.landing-hero {
  position: relative;
  width: 100%;
  max-width: 100%;
  padding: 2rem 1.75rem 2.15rem;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.07);
  background: linear-gradient(165deg, #ffffff 0%, #fafbfc 55%, #f8fafc 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 12px 40px rgba(15, 23, 42, 0.07),
    0 2px 8px rgba(15, 23, 42, 0.04);
  text-align: center;
  overflow: hidden;
}

.landing-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, transparent, rgba(13, 148, 136, 0.55), rgba(14, 165, 233, 0.45), transparent);
  opacity: 0.9;
}

.landing-kicker {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.28rem 0.75rem;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #0f766e;
  background: rgba(13, 148, 136, 0.1);
  border: 1px solid rgba(13, 148, 136, 0.22);
  border-radius: 999px;
}

.landing-title {
  margin: 0 0 0.95rem;
  font-size: clamp(1.45rem, 2.8vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.038em;
  line-height: 1.2;
  color: var(--text);
  max-width: 44rem;
  margin-left: auto;
  margin-right: auto;
}

.landing-lead {
  margin: 0;
  max-width: 48rem;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--muted);
}

.landing-projects {
  width: 100%;
  max-width: 100%;
  margin-top: 0;
  padding: 1.1rem 1.2rem 1.15rem;
  text-align: left;
  align-self: stretch;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.07);
  background: var(--surface-card);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
}

.landing-projects:not([hidden]) {
  display: block;
}

.landing-projects-head {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.landing-projects-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: min(36vh, 260px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.main {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 900px) {
  .main {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .main > .panel {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    align-self: stretch;
  }
}

@media (max-width: 899px) {
  .main {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 280px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 900px) {
  .workspace .panel {
    min-height: 0;
  }
}

/* Chat column: thread scrolls; composer docks at bottom of this column only (active workspace). */
.panel.panel-chat {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel.panel-chat .composer-active-anchor {
  flex: 0 0 auto;
  border-top: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.35) 0%, rgba(248, 250, 252, 0.9) 100%);
}

.panel.panel-chat .composer-dock {
  padding: 0.65rem 0.65rem 0.75rem;
  margin-top: 0;
  border-top: none;
  background: transparent;
}

.panel.panel-chat .composer-dock-stack {
  max-width: none;
  width: 100%;
  margin: 0;
}

.panel.panel-chat .composer-dock .composer {
  padding: 0.85rem 0.7rem 0.95rem;
}

@media (min-width: 900px) {
  .panel.panel-plan {
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  .panel.panel-plan .plan-body {
    flex: 0 0 auto;
    overflow-y: visible;
    min-height: 0;
  }
}

.panel-body-scroll {
  display: flex;
  flex-direction: column;
  flex: 1;
}

@media (min-width: 900px) {
  .panel-body-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.plan-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.version-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  letter-spacing: 0.03em;
  text-transform: none;
}

.history {
  border-bottom: 1px solid var(--border);
  background: var(--surface-shade);
}

.history > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 1.1rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  user-select: none;
}

.history > summary::-webkit-details-marker {
  display: none;
}

.history > summary::after {
  content: " ▾";
  font-size: 0.7rem;
  color: var(--muted);
}

.history[open] > summary::after {
  content: " ▴";
}

.history-list {
  padding: 0 1.1rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
}

.history-item:hover,
.history-item:focus-visible {
  border-color: #cbd5e1;
  outline: none;
}

.history-item.active {
  border-color: var(--accent);
  background: rgba(13, 148, 136, 0.1);
}

.history-item .v-id {
  font-family: var(--mono);
  color: var(--accent);
  min-width: 2.6rem;
  font-size: 0.78rem;
}

.history-item .v-summary {
  flex: 1;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .v-time {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 899px) {
  .thread {
    max-height: min(44vh, 340px);
  }
}

.panel.panel-chat .thread {
  flex: 1 1 auto;
  min-height: 0;
}

.theme-picker {
  flex-shrink: 0;
  padding: 0.85rem 1.1rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.95) 0%, var(--surface-shade) 100%);
}

@media (min-width: 900px) {
  .panel.panel-plan .theme-picker.theme-picker--open {
    position: sticky;
    top: 0;
    z-index: 3;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  }
}

.theme-picker[hidden] {
  display: none !important;
}

.theme-picker.theme-picker--open {
  display: block;
}

.theme-picker-title {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.5rem;
}

.theme-swatch {
  position: relative;
  min-height: 58px;
  border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  background: transparent;
}

/* Gradient on a child avoids native <button> background reset in some browsers */
.theme-swatch-fill {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
}

.theme-swatch:hover,
.theme-swatch:focus-visible {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px #6366f133;
}

.theme-swatch-label {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  padding: 0.35rem 0.4rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  color: #f8fafc;
  text-shadow: 0 1px 2px #000c;
  background: linear-gradient(transparent, rgba(15, 18, 24, 0.72));
  pointer-events: none;
}

.bubble {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-user {
  align-self: flex-end;
  max-width: 92%;
  background: var(--bubble-user-bg);
  border: 1px solid var(--bubble-user-border);
}

.bubble-assistant {
  align-self: stretch;
  background: var(--bubble-assistant-bg);
  border: 1px solid var(--bubble-assistant-border);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--code-text);
}

.bubble-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bubble-assistant.bubble-has-attachment {
  font-family: var(--font);
  font-size: 0.92rem;
  color: var(--text);
}

.bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-assistant .bubble-body {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--code-text);
}

.thread-file.thread-file-btn {
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-inset);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.thread-file-btn:hover {
  border-color: #cbd5e1;
  background: var(--surface-inset);
}

.thread-file-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.thread-file-icon {
  flex-shrink: 0;
  color: var(--muted);
  vertical-align: middle;
}

.thread-file-name {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: #0e7490;
  word-break: break-all;
  text-align: left;
}

.thread-file-hint {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}

.composer-active-anchor {
  flex: 0 0 auto;
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
}

.workspace--active .composer-active-anchor {
  display: flex;
}

.composer-dock {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.85rem 0 1.35rem;
  margin-top: auto;
  border-top: 1px solid var(--hairline);
  background: linear-gradient(180deg, transparent 0%, rgba(248, 250, 252, 0.75) 38%);
}

.composer-idle-anchor .composer-dock {
  padding: 0 0 0.1rem;
  margin-top: 0;
  border-top: none;
  background: transparent;
}

.composer-idle-anchor .composer-dock .composer {
  padding: 0;
  border: none;
  border-top: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  gap: 0.75rem;
}

.workspace--idle .composer-idle-anchor .composer-dock-stack {
  max-width: none;
}

.composer-dock-stack {
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.workspace--idle .composer-idle-anchor .composer-dock-stack {
  max-width: none;
}

.composer-dock .composer {
  max-width: none;
  margin: 0;
  width: 100%;
  border-top: none;
  padding: 1.15rem 1.25rem 1.25rem;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 10px 36px rgba(15, 23, 42, 0.07),
    0 2px 6px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.composer {
  padding: 1rem 1.1rem 1.15rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-inset);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea::placeholder {
  color: var(--muted);
}

textarea:focus {
  outline: none;
  border-color: rgba(13, 148, 136, 0.45);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.prompt-sheet {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.prompt-sheet textarea {
  display: block;
  width: 100%;
  min-height: min(280px, 44vh);
  resize: vertical;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 1.15rem 1.2rem 0.5rem;
  font-size: 1.02rem;
  line-height: 1.55;
  background: #fafbfc;
}

/* Landing: leave room for footer actions on short laptop screens */
.workspace--idle .prompt-sheet textarea {
  min-height: clamp(100px, 28dvh, 200px);
  max-height: 50dvh;
}

.workspace--active .prompt-sheet textarea {
  min-height: 110px;
  font-size: 0.95rem;
  padding: 0.85rem 1rem 0.4rem;
}

.prompt-sheet textarea:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.35);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.2rem;
  min-height: 2.45rem;
}

.composer-actions.prompt-sheet-footer {
  margin: 0;
  padding: 0.7rem 1rem 0.85rem;
  border-top: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), #f4f6f8);
  min-height: 2.6rem;
}

.composer-actions.prompt-sheet-footer .btn.primary {
  padding: 0.5rem 1.15rem;
  border-radius: 10px;
}

.composer-actions .hint {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.composer-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  flex: 1;
}

.composer-status .hint {
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  flex-shrink: 0;
  height: 1rem;
}

.status-dots[hidden] {
  display: none !important;
}

.status-dot {
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: status-dot-pulse 0.95s ease-in-out infinite;
}

.status-dot:nth-child(2) {
  animation-delay: 0.16s;
}

.status-dot:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes status-dot-pulse {
  0%,
  70%,
  100% {
    opacity: 0.3;
    transform: translateY(0) scale(0.92);
  }

  35% {
    opacity: 1;
    transform: translateY(-2px) scale(1);
  }
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.hint.error {
  color: var(--danger);
}

.hint.success {
  color: #0f766e;
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0.01em;
}

.composer-status--success {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.14), rgba(13, 148, 136, 0.07));
  border: 1px solid rgba(13, 148, 136, 0.35);
  border-radius: 9px;
  padding: 0.28rem 0.55rem;
  margin: -0.12rem -0.2rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}

.composer-actions .hint.success {
  font-size: 0.86rem;
  font-weight: 600;
  color: #0d9488;
}

.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.panel-head .btn.primary {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.btn.primary {
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(13, 148, 136, 0.22);
  transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.btn--with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.btn--with-icon .btn-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.04);
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.28);
}

.btn.primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn.ghost:hover {
  color: var(--text);
  border-color: #cbd5e1;
}

.plan-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem 1.25rem;
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.plan-summary {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--accent);
}

.plan-name {
  font-size: 0.85rem;
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 0 0 0.35rem;
  color: var(--muted);
  word-break: break-all;
}

.plan-section {
  margin-bottom: 1.25rem;
}

/* Collapsible plan blocks (Pages / Widgets), aligned with version history pattern */
.plan-collapsible {
  background: var(--surface-shade);
  margin-bottom: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.plan-collapsible > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.plan-collapsible > summary::-webkit-details-marker {
  display: none;
}

.plan-collapsible > summary::after {
  content: " ▾";
  font-size: 0.7rem;
  color: var(--muted);
  flex-shrink: 0;
}

.plan-collapsible[open] > summary::after {
  content: " ▴";
}

.plan-collapsible-body {
  padding: 0 0.85rem 0.85rem;
}

.plan-card {
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-inset);
  margin-bottom: 0.5rem;
}

.plan-card:last-child {
  margin-bottom: 0;
}

.plan-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 0.65rem;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  user-select: none;
}

.plan-card > summary::-webkit-details-marker {
  display: none;
}

.plan-eye {
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: var(--accent);
  opacity: 0.85;
}

.plan-card[open] .plan-eye {
  opacity: 1;
}

.plan-card-summary-main {
  flex: 1;
  min-width: 0;
}

.plan-card-summary-main h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}

.plan-card-summary-main .id {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.plan-card-teaser {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plan-card-body {
  padding: 0 0.65rem 0.65rem 2.35rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--code-text);
}

.plan-card-body strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0.65rem 0 0.2rem;
}

.plan-card-body strong:first-of-type {
  margin-top: 0;
}

.plan-card-body p:last-child {
  margin-bottom: 0;
}

.plan-card-meta {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.plan-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Legacy flat cards (if any) */
.card {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-shade);
}

.card h4 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.card .id {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

ul.tags {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.raw-fallback {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 8px;
  background: var(--surface-inset);
  border: 1px dashed var(--border);
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

.confirm-bar {
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--border);
  background: #ecfdf5;
  color: #0f766e;
  font-size: 0.82rem;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  word-break: break-all;
}

.projects-section {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.projects-list {
  padding: 0.7rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 260px;
  overflow-y: auto;
}

.project-item {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.project-item:hover,
.project-item:focus-visible {
  border-color: #cbd5e1;
  outline: none;
  box-shadow: var(--shadow-sm);
}

.project-item h5 {
  margin: 0 0 0.15rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.project-item p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.project-item .row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.3rem;
  font-family: var(--mono);
}

.confirm-bar::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.build-progress-banner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.65rem 0 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--text);
  font-size: 0.9rem;
}

.build-progress-banner__spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(13, 148, 136, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: workspace-loader-spin 0.75s linear infinite;
  flex-shrink: 0;
}

.build-progress-banner__text strong {
  color: var(--accent);
  font-weight: 600;
}

.build-progress-track {
  height: 4px;
  margin: 0 0 0.75rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.build-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #2dd4bf);
  transition: width 0.35s ease;
}

.build-group-heading {
  margin: 0.75rem 0 0.35rem;
  padding: 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
}

.build-group-heading:first-child {
  margin-top: 0;
}

.build-status-pill {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.68rem;
  font-family: var(--mono);
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.build-row-mark {
  flex-shrink: 0;
  width: 1.1rem;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--muted);
  font-family: var(--mono);
}

.build-row-mark--generating {
  color: var(--accent);
}

.build-row-mark--ok {
  color: #16a34a;
}

.build-row-mark--error {
  color: #b45309;
}

.build-row--generating {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.15);
}

.build-row--generating .build-name {
  font-weight: 600;
  color: var(--text);
}

.build-row--generating .build-status-pill {
  color: var(--accent);
  border-color: var(--accent);
  background: #fff;
}

.build-icon--generating .build-icon__spinner {
  border-top-color: var(--accent);
}

.build-icon__spinner--dim {
  opacity: 0.45;
}

.build-section {
  border-top: 1px solid var(--border);
  background: var(--surface-shade);
  display: flex;
  flex-direction: column;
}

.validation-panel {
  margin: 0.65rem 1.1rem 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: rgba(254, 242, 242, 0.65);
}

.validation-panel--ok {
  border-color: rgba(13, 148, 136, 0.35);
  background: rgba(236, 253, 245, 0.75);
}

.validation-panel--ok .validation-panel__title {
  color: var(--accent);
}

.validation-panel[hidden] {
  display: none !important;
}

.validation-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.55rem;
}

.validation-panel__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--danger);
}

.validation-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(28vh, 220px);
  overflow-y: auto;
}

.validation-file {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(220, 38, 38, 0.2);
  background: var(--bg-elevated);
}

.validation-file__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.validation-file__path {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
  word-break: break-all;
}

.validation-file__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.validation-file__fix {
  flex-shrink: 0;
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
}

.build-row--validation-error {
  border-color: rgba(220, 38, 38, 0.45) !important;
  background: rgba(254, 242, 242, 0.5) !important;
}

.build-row--validation-error .build-icon--ok {
  color: #dc2626;
}

.build-row-validation-hint {
  flex: 1 1 100%;
  margin: 0 0 0 2rem;
  font-size: 0.75rem;
  color: #991b1b;
  line-height: 1.35;
  text-align: left;
}

.build-row-fix {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.3rem 0.55rem;
}

.validation-file ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: #7f1d1d;
}

.validation-file li {
  margin: 0.2rem 0;
}

.ui-review-panel {
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(255, 251, 235, 0.75);
}

.ui-review-panel.ui-review-panel--ok {
  border-color: rgba(13, 148, 136, 0.35);
  background: rgba(236, 253, 245, 0.75);
}

.ui-review-panel.ui-review-panel--ok .validation-panel__title {
  color: var(--accent);
}

.ui-review-panel:not(.ui-review-panel--ok) .validation-panel__title {
  color: #b45309;
}

.build-row--ui-review-fail {
  border-color: rgba(180, 83, 9, 0.45) !important;
  background: rgba(255, 251, 235, 0.45) !important;
}

.build-row-ui-hint {
  flex: 1 1 100%;
  margin: 0 0 0 2rem;
  font-size: 0.75rem;
  color: #92400e;
  line-height: 1.35;
  text-align: left;
}

.ui-review-issue--error {
  color: #991b1b;
}

.ui-review-issue--warning {
  color: #92400e;
}

.build-list {
  padding: 0.7rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: min(42vh, 320px);
  overflow-y: auto;
}

.build-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
}

.build-icon--ok {
  color: var(--accent);
}

.build-icon--error {
  color: #f59e0b;
}

.build-icon--pending {
  color: var(--muted);
}

.build-icon__spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid rgba(13, 148, 136, 0.2);
  border-top-color: var(--accent);
  animation: workspace-loader-spin 0.75s linear infinite;
}

.build-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.build-row--with-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0;
  border: none;
  background: transparent;
  cursor: default;
}

.build-row--with-actions .build-row-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 0.85rem;
  text-align: left;
  color: var(--text);
}

.build-row--with-actions .build-row-main:hover,
.build-row--with-actions .build-row-main:focus-visible {
  border-color: #cbd5e1;
  outline: none;
}

.build-row--with-actions .build-row-convert {
  align-self: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.35rem 0.55rem;
}

.build-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 0.85rem;
  text-align: left;
  color: var(--text);
}

.build-row--pending {
  cursor: default;
  opacity: 0.92;
}

.build-row--pending:disabled,
.build-row--ok:disabled {
  cursor: default;
}

.build-row--ok:not(:disabled):hover,
.build-row--ok:not(:disabled):focus-visible {
  border-color: #cbd5e1;
  outline: none;
}

.build-row:hover,
.build-row:focus-visible {
  border-color: #cbd5e1;
  outline: none;
}

.build-row.error {
  border-color: #78350f55;
  background: #2a160933;
}

.build-row.error:hover,
.build-row.error:focus-visible {
  border-color: #b45309;
  outline: none;
}

.build-row.retrying {
  opacity: 0.7;
  cursor: progress;
}

.retry-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

.build-kind {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 4.5rem;
}

.build-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.build-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.build-badge.ok {
  background: var(--accent-dim);
  color: var(--accent);
}

.build-badge.error {
  background: #78350f55;
  color: #fcd34d;
}

.artifact-dialog {
  max-width: min(900px, 92vw);
  max-height: 80vh;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0;
  overflow: hidden;
}

.artifact-dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.artifact-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.artifact-dialog-head h3 {
  margin: 0;
  font-size: 1rem;
}

.artifact-kind {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.artifact-json-wrap {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  max-height: calc(80vh - 64px);
  overflow: auto;
  background: var(--surface-inset);
}

.artifact-line-gutter {
  flex: 0 0 auto;
  margin: 0;
  padding: 1rem 0.55rem 1rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: right;
  user-select: none;
  white-space: pre;
  tab-size: 2;
  border-right: 1px solid var(--border);
  background: var(--surface-shade);
  min-width: 2.5rem;
}

.artifact-json {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--code-text);
  white-space: pre;
  overflow: visible;
  tab-size: 2;
}

.failure-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.88rem;
  line-height: 1.45;
}

.failure-banner[hidden] {
  display: none !important;
}

.failure-banner--build {
  margin: 0 0 0.65rem;
}

.failure-banner__text {
  flex: 1;
  min-width: 12rem;
  margin: 0;
}

.panel-actions #btn-retry-failed:not([hidden]) {
  border-color: #f87171;
  color: #b91c1c;
  background: #fef2f2;
}

.warn-banner {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #92400e;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
