:root {
  --bg: #f2f7f8;
  --panel: #ffffff;
  --panel-2: #e9f1f4;
  --text: #0d1f2d;
  --sub: #4a6172;
  --brand: #006d77;
  --brand-2: #0a9396;
  --accent: #ee9b00;
  --danger: #bb3e03;
  --ok: #2a9d8f;
  --warn: #ca6702;
  --line: #d0dde3;
  --shadow: 0 10px 28px rgba(16, 42, 67, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", "Heiti SC", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 15%, #d6ebee 0%, #f2f7f8 42%),
    radial-gradient(circle at 85% 10%, #fbe8c5 0%, transparent 35%),
    var(--bg);
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  min-height: 100vh;
}

body.studio-popup-mode .app-shell {
  grid-template-columns: 1fr;
}

body.studio-popup-mode .sidebar,
body.studio-popup-mode .ai-panel,
body.studio-popup-mode .topbar {
  display: none !important;
}

body.studio-popup-mode .main-area {
  padding: 12px;
  background:
    radial-gradient(circle at 6% 4%, rgba(10, 147, 150, 0.1) 0%, transparent 22%),
    radial-gradient(circle at 94% 10%, rgba(238, 155, 0, 0.12) 0%, transparent 25%),
    linear-gradient(180deg, #eaf4f7 0%, #dce9ef 100%);
}

body.studio-popup-mode .content {
  gap: 10px;
}

body.login-mode .app-shell {
  grid-template-columns: 1fr;
}

body.login-mode .sidebar,
body.login-mode .ai-panel,
body.login-mode .topbar {
  display: none !important;
}

body.login-mode .main-area {
  min-height: 100vh;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 12% 10%, rgba(10, 147, 150, 0.14) 0%, transparent 26%),
    radial-gradient(circle at 86% 12%, rgba(238, 155, 0, 0.18) 0%, transparent 30%),
    linear-gradient(180deg, #e7f2f6 0%, #dce9ef 100%);
}

body.login-mode .content {
  width: min(520px, calc(100vw - 32px));
}

.sidebar {
  background: linear-gradient(180deg, #043c4d 0%, #075c66 55%, #0a7b82 100%);
  color: #ecf7f8;
  padding: 18px 14px;
  overflow-y: auto;
}

.brand {
  margin-bottom: 18px;
}

.brand h2 {
  margin: 2px 0;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.brand p {
  margin: 0;
  opacity: 0.85;
  font-size: 12px;
}

.project-context {
  margin: 10px 0 16px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.project-context p {
  margin: 0 0 6px;
  font-size: 11px;
  opacity: 0.88;
}

.project-context strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.project-context select {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
}

.nav-group {
  margin-bottom: 14px;
}

.nav-group-title {
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 8px;
}

.nav-link {
  display: block;
  color: #f6feff;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 4px;
  transition: all 0.18s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  transform: translateX(2px);
}

.main-area {
  padding: 20px;
  overflow-y: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--sub);
}

#page-title {
  margin: 4px 0 0;
  font-size: 25px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 12px;
  background: #fff;
}

.content {
  display: grid;
  gap: 12px;
}

.project-view-nav {
  padding: 12px;
}

.project-view-head h3 {
  margin: 2px 0 6px;
  font-size: 18px;
}

.project-view-links {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.project-view-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--brand);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
  background: #fff;
  font-size: 12px;
}

.project-view-link:hover,
.project-view-link.active {
  border-color: #7ac3c6;
  background: #f0fbfb;
  color: #075c66;
}

.login-wrap {
  width: 100%;
}

.login-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(168deg, #ffffff 0%, #f5fafc 100%);
  box-shadow: var(--shadow);
  padding: 24px 24px 20px;
}

.login-card h2 {
  margin: 8px 0 8px;
  font-size: 28px;
}

.login-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.login-form label {
  font-size: 12px;
  color: var(--sub);
}

.login-submit {
  margin-top: 6px;
  width: 100%;
}

.login-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--sub);
}

.login-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.project-flow-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.flow-legend-item {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 3px 10px;
  font-size: 12px;
  background: #fff;
  color: var(--sub);
}

.flow-legend-item.done {
  border-color: #a6d8d2;
  background: #ebfaf8;
  color: #0d685f;
}

.flow-legend-item.active {
  border-color: #ebcf9f;
  background: #fff7e8;
  color: #7a4b00;
}

.flow-legend-item.pending {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #475569;
}

.project-flow-canvas {
  overflow-x: hidden;
  overflow-y: visible;
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.project-flow-stages {
  display: grid;
  grid-template-columns: repeat(var(--flow-cols, 3), minmax(0, 1fr));
  column-gap: 34px;
  row-gap: 24px;
  align-items: stretch;
  padding: 4px 4px 8px;
}

.flow-stage {
  min-width: 0;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(170deg, #ffffff 0%, #f5fafc 100%);
  box-shadow: 0 8px 18px rgba(14, 44, 65, 0.08);
}

.flow-stage.link-right::after {
  content: "";
  position: absolute;
  right: -27px;
  top: 42%;
  width: 20px;
  height: 2px;
  background: #9bb8c3;
}

.flow-stage.link-right::before {
  content: "";
  position: absolute;
  right: -27px;
  top: calc(42% - 5px);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid #9bb8c3;
}

.flow-stage.link-left::after {
  content: "";
  position: absolute;
  left: -27px;
  top: 42%;
  width: 20px;
  height: 2px;
  background: #9bb8c3;
}

.flow-stage.link-left::before {
  content: "";
  position: absolute;
  left: -27px;
  top: calc(42% - 5px);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 9px solid #9bb8c3;
}

.flow-stage.link-down::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -20px;
  width: 2px;
  height: 16px;
  transform: translateX(-50%);
  background: #9bb8c3;
}

.flow-stage.link-down::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -24px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #9bb8c3;
}

.flow-stage.done {
  border-color: #8ecfc8;
}

.flow-stage.active {
  border-color: #e6c68f;
}

.flow-stage.pending {
  border-color: #cdd8e2;
}

.flow-stage-order {
  width: 30px;
  text-align: center;
  border: 1px solid #bcd4de;
  background: #f1f8fb;
  border-radius: 999px;
  font-size: 11px;
  color: #2f4f61;
  margin-bottom: 6px;
}

.flow-stage h4 {
  margin: 0 0 5px;
  font-size: 15px;
}

.flow-stage-window {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--sub);
}

.flow-stage-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e6f0f4;
  overflow: hidden;
}

.flow-stage-progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(120deg, #0a9396, #75c8c8);
}

.flow-stage-rate {
  margin: 6px 0 8px;
  font-size: 11px;
  color: var(--sub);
}

.flow-node-list {
  display: grid;
  gap: 6px;
}

.flow-node {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 8px;
  background: #fff;
}

.flow-node.done {
  border-left: 4px solid #0d685f;
  background: #ebfaf8;
}

.flow-node.active {
  border-left: 4px solid #ca6702;
  background: #fff8ed;
}

.flow-node.pending {
  border-left: 4px solid #64748b;
  background: #f8fafc;
}

.flow-node-title {
  margin: 0 0 3px;
  font-size: 12px;
  color: var(--text);
}

.flow-node-meta {
  margin: 0;
  font-size: 11px;
  color: var(--sub);
}

.flow-timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.flow-time-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.flow-time-item:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -14px;
  top: 50%;
  width: 10px;
  height: 2px;
  background: #9bb8c3;
}

.flow-time-item p {
  margin: 0 0 3px;
  font-size: 11px;
  color: var(--sub);
}

.flow-time-item strong {
  font-size: 13px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 10px;
  font-size: 16px;
}

.card-sub {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--sub);
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 12px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(150deg, #ffffff 0%, #f3f8fa 100%);
}

.metric p {
  margin: 0;
}

.metric .k {
  font-size: 11px;
  color: var(--sub);
}

.metric .v {
  font-size: 24px;
  margin-top: 3px;
  font-weight: 700;
}

.metric .t {
  font-size: 12px;
  margin-top: 2px;
}

.btn {
  border: none;
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

.btn.ghost {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
}

.btn.warn {
  background: linear-gradient(120deg, #c45e00 0%, #ee9b00 100%);
}

.btn.danger {
  background: linear-gradient(120deg, #9e2a2b 0%, #bb3e03 100%);
}

.btn.small {
  padding: 5px 8px;
  font-size: 12px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #edf4f6;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 0.25px;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid transparent;
}

.tag.high,
.tag.overdue,
.tag.blocked,
.tag.rejected {
  color: #8e1d1d;
  border-color: #e2acac;
  background: #fff2f2;
}

.tag.mid,
.tag.pending,
.tag.conditional,
.tag.review {
  color: #7a4b00;
  border-color: #ebcf9f;
  background: #fff7e8;
}

.tag.low,
.tag.done,
.tag.passed,
.tag.closed,
.tag.released {
  color: #0d685f;
  border-color: #a6d8d2;
  background: #ebfaf8;
}

.tag.draft {
  color: #475569;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 12px;
}

.split > * {
  min-width: 0;
}

.progress {
  width: 100%;
  height: 8px;
  background: #e4edf1;
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(120deg, var(--brand-2), var(--accent));
}

.timeline {
  border-left: 2px solid #c8d9de;
  padding-left: 12px;
}

.timeline-item {
  margin-bottom: 10px;
}

.timeline-item p {
  margin: 2px 0;
}

.ai-panel {
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, #f9fbfc 0%, #edf4f7 100%);
  padding: 16px;
  overflow-y: auto;
  min-width: 0;
  overflow-x: hidden;
}

.ai-head {
  margin-bottom: 10px;
}

.ai-head h3 {
  margin: 0;
}

.ai-context {
  font-size: 12px;
  color: var(--sub);
  margin-top: 4px;
}

.ai-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  min-width: 0;
  overflow: hidden;
}

.ai-card p {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--sub);
}

.ai-last-output {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  background: #f8fbfc;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-inline-result {
  border-left: 3px solid #7ac3c6;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4fbfc;
}

.ai-history {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.ai-history-item {
  display: block;
  width: 100%;
  max-width: 100%;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 8px;
  color: inherit;
  overflow: hidden;
}

.ai-history-item:hover {
  border-color: #7ac3c6;
  background: #f0fbfb;
}

.ai-history-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--sub);
  margin-bottom: 4px;
  min-width: 0;
}

.ai-history-head span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-history-text {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(13, 31, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: min(900px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 10px;
  min-height: min(68vh, 560px);
}

.modal-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fafc;
  padding: 8px;
  overflow: auto;
}

.modal-list-item {
  display: block;
  width: 100%;
  max-width: 100%;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 7px 8px;
  margin-bottom: 6px;
  overflow: hidden;
}

.modal-list-item:last-child {
  margin-bottom: 0;
}

.modal-list-item:hover,
.modal-list-item.active {
  border-color: #7ac3c6;
  background: #f0fbfb;
}

.modal-list-line {
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 3px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-list-line.sub {
  font-size: 11px;
  color: var(--sub);
}

.modal-detail {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-pre {
  margin: 0;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  white-space: normal;
  line-height: 1.5;
  font-size: 13px;
  max-height: min(66vh, 620px);
  overflow: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.studio-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  background: linear-gradient(135deg, #f8fcfd 0%, #eff9fb 42%, #fff7eb 100%);
  border-color: #bcd4dd;
  box-shadow: 0 14px 34px rgba(9, 48, 66, 0.12);
}

.studio-page {
  position: relative;
  display: grid;
  gap: 12px;
}

.studio-page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% -6%, rgba(10, 147, 150, 0.12) 0%, transparent 35%),
    radial-gradient(circle at 95% 12%, rgba(238, 155, 0, 0.12) 0%, transparent 30%);
}

.studio-hero::after {
  content: "";
  position: absolute;
  right: -90px;
  top: -90px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(10, 147, 150, 0.18) 0%, rgba(10, 147, 150, 0) 72%);
  pointer-events: none;
}

.studio-hero-main {
  max-width: min(920px, 100%);
}

.studio-hero h2 {
  margin: 4px 0 8px;
  font-size: 38px;
  letter-spacing: 0.2px;
}

.studio-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.studio-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #115166;
  border: 1px solid #b8dbe2;
  background: rgba(255, 255, 255, 0.82);
}

.studio-layout-main {
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 320px;
  grid-template-rows: minmax(0, 1fr) 360px;
  gap: 12px;
  height: clamp(820px, 92vh, 960px);
  max-height: clamp(820px, 92vh, 960px);
  min-height: 0;
  align-items: stretch;
}

.studio-pane {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: #c6dbe2;
  box-shadow: 0 8px 20px rgba(10, 42, 67, 0.08);
  animation: studioPaneIn 0.32s ease both;
}

.studio-pane:nth-child(2) {
  animation-delay: 0.02s;
}

.studio-pane:nth-child(3) {
  animation-delay: 0.04s;
}

.studio-pane:nth-child(4) {
  animation-delay: 0.06s;
}

.studio-pane:nth-child(5) {
  animation-delay: 0.08s;
}

@keyframes studioPaneIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.studio-pane-soft {
  background: linear-gradient(180deg, #fbfeff 0%, #f3f9fb 100%);
}

.studio-pane-focus {
  border-color: #9fcfd8;
  box-shadow: 0 10px 26px rgba(10, 42, 67, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.studio-pane-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.studio-pane-badge {
  min-width: 26px;
  text-align: center;
  border-radius: 999px;
  background: #e3f1f5;
  color: #115166;
  border: 1px solid #c3e1e9;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
}

.studio-left-top {
  grid-column: 1;
  grid-row: 1;
}

.studio-left-bottom {
  grid-column: 1;
  grid-row: 2;
}

.studio-center {
  grid-column: 2;
  grid-row: 1 / span 2;
  background: linear-gradient(180deg, #ffffff 0%, #f6fcfd 100%);
}

.studio-right-top {
  grid-column: 3;
  grid-row: 1;
}

.studio-right-bottom {
  grid-column: 3;
  grid-row: 2;
}

.studio-chat-head {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #d7e6ec;
}

.studio-chat-head h3 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0.2px;
  color: #0c2a3d;
}

.studio-chat-stream {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid #bdd6df;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfeff 0%, #f6fbfd 100%);
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  scroll-behavior: smooth;
}

.studio-chat-input {
  margin-top: 10px;
  border-top: 1px solid #d8e8ee;
  padding-top: 10px;
}

.studio-chat-input textarea {
  height: 120px;
  min-height: 120px;
  max-height: 120px;
  resize: none;
  border-color: #b8d4de;
  background: #fdfefe;
  box-shadow: inset 0 1px 1px rgba(12, 42, 61, 0.06);
}

.studio-source-item,
.studio-target-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid #c6dbe2;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  margin-bottom: 8px;
  transition: all 0.16s ease;
}

.studio-source-item:hover,
.studio-target-item:hover {
  border-color: #9cc8d2;
  background: #f5fbfc;
  transform: translateY(-1px);
}

.studio-source-item input[type='checkbox'],
.studio-target-item input[type='checkbox'] {
  margin-top: 2px;
  accent-color: #0a9396;
}

.studio-source-item input[type='checkbox']:checked + div,
.studio-target-item input[type='checkbox']:checked + div {
  border-radius: 6px;
  background: rgba(10, 147, 150, 0.08);
  padding: 4px 6px;
}

#studio-core-sources,
#studio-uploaded-sources,
#studio-target-list,
#studio-generated-list {
  overflow: auto;
  min-height: 0;
  max-height: none;
}

#studio-core-sources,
#studio-uploaded-sources,
#studio-target-list {
  flex: 1 1 auto;
}

#studio-generated-list {
  flex: 0 0 42%;
}

.studio-source-title {
  margin: 0 0 3px;
  font-size: 12px;
  color: #143548;
  font-weight: 600;
}

.studio-source-sub {
  margin: 0;
  font-size: 11px;
  color: #4f6879;
  line-height: 1.4;
}

.studio-source-title .chip {
  padding: 2px 7px;
  font-size: 10px;
  border-color: #bfdce3;
  background: #f2fafc;
  color: #155166;
}

.studio-generated-item {
  border: 1px solid #bfd7e0;
  border-radius: 10px;
  padding: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fcfd 100%);
  margin-bottom: 8px;
  transition: all 0.16s ease;
}

.studio-generated-item:hover {
  border-color: #99c4ce;
  transform: translateY(-1px);
}

.studio-generated-item.active {
  border-color: #7ac3c6;
  background: linear-gradient(180deg, #f0fbfb 0%, #e7f7f8 100%);
  box-shadow: inset 0 0 0 1px rgba(122, 195, 198, 0.28);
}

.studio-generated-preview {
  margin-top: 8px;
  border: 1px solid #c5dbe3;
  border-radius: 10px;
  background: linear-gradient(180deg, #f9fcfe 0%, #f1f8fb 100%);
  padding: 8px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.studio-msg {
  margin-bottom: 10px;
  border: 1px solid #c2d8e1;
  border-radius: 10px;
  padding: 9px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fcfd 100%);
  box-shadow: 0 2px 8px rgba(11, 44, 63, 0.06);
}

.studio-msg.user {
  border-left: 4px solid #ca6702;
  background: linear-gradient(180deg, #fffaf2 0%, #fff5e8 100%);
}

.studio-msg.assistant {
  border-left: 4px solid #0a9396;
  background: linear-gradient(180deg, #f3fbfc 0%, #ecf8fa 100%);
}

.studio-msg-meta {
  font-size: 11px;
  color: #466173;
  margin-bottom: 6px;
}

.studio-md {
  font-size: 13px;
  line-height: 1.55;
  color: #0f2d3f;
  overflow-wrap: anywhere;
}

.studio-md h2,
.studio-md h3,
.studio-md h4 {
  margin: 10px 0 6px;
}

.studio-md p {
  margin: 4px 0;
}

.studio-md-ul,
.studio-md-ol {
  margin: 6px 0;
  padding-left: 20px;
}

.studio-md-gap {
  height: 6px;
}

.studio-md-pre {
  margin: 8px 0;
  border: 1px solid #c8dce4;
  border-radius: 8px;
  background: #eff6fa;
  padding: 10px;
  overflow: auto;
  font-size: 12px;
}

.studio-md-code {
  background: #ecf3f7;
  border: 1px solid #d4e2ea;
  border-radius: 6px;
  padding: 0 4px;
  font-size: 12px;
}

#studio-generate-prompt {
  border-color: #b8d4de;
  background: #fcfefe;
  min-height: 92px;
}

.studio-pane .btn {
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.studio-pane .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(10, 42, 67, 0.12);
}

#studio-core-sources,
#studio-uploaded-sources,
#studio-target-list,
#studio-generated-list,
.studio-generated-preview,
.studio-chat-stream {
  scrollbar-width: thin;
  scrollbar-color: #9ec3cf #eef6f9;
}

#studio-core-sources::-webkit-scrollbar,
#studio-uploaded-sources::-webkit-scrollbar,
#studio-target-list::-webkit-scrollbar,
#studio-generated-list::-webkit-scrollbar,
.studio-generated-preview::-webkit-scrollbar,
.studio-chat-stream::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

#studio-core-sources::-webkit-scrollbar-track,
#studio-uploaded-sources::-webkit-scrollbar-track,
#studio-target-list::-webkit-scrollbar-track,
#studio-generated-list::-webkit-scrollbar-track,
.studio-generated-preview::-webkit-scrollbar-track,
.studio-chat-stream::-webkit-scrollbar-track {
  background: #edf6f9;
  border-radius: 999px;
}

#studio-core-sources::-webkit-scrollbar-thumb,
#studio-uploaded-sources::-webkit-scrollbar-thumb,
#studio-target-list::-webkit-scrollbar-thumb,
#studio-generated-list::-webkit-scrollbar-thumb,
.studio-generated-preview::-webkit-scrollbar-thumb,
.studio-chat-stream::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #9ec3cf, #7caebb);
  border-radius: 999px;
  border: 2px solid #edf6f9;
}

.badge-large {
  font-size: 30px;
  font-weight: 700;
  margin: 2px 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 9px;
  font-size: 13px;
  background: #fff;
}

textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.stepper {
  display: grid;
  gap: 6px;
}

.step {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  font-size: 12px;
}

.step.active {
  border-color: #7ac3c6;
  background: #f0fbfb;
}

.contract-wizard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 12px;
}

.contract-wizard-grid > * {
  min-width: 0;
}

.contract-wizard-grid .span-full {
  grid-column: 1 / -1;
}

.contract-flow-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.contract-flow-step {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(14, 44, 65, 0.06);
}

.contract-flow-step.done {
  border-color: #8ecfc8;
  background: #ebfaf8;
}

.contract-flow-step.active {
  border-color: #7ac3c6;
  background: #f0fbfb;
  box-shadow: 0 10px 18px rgba(10, 147, 150, 0.16);
}

.contract-flow-step.pending {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.contract-flow-step-no {
  margin: 0 0 5px;
  font-size: 11px;
  color: var(--sub);
  letter-spacing: 0.4px;
}

.contract-flow-step h4 {
  margin: 0 0 5px;
  font-size: 14px;
}

.contract-flow-step-goal {
  margin: 0 0 7px;
  font-size: 12px;
  color: var(--text);
}

.contract-flow-step-io {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--sub);
}

.contract-flow-step-owner {
  margin: 0;
  font-size: 11px;
  color: var(--sub);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kanban-col {
  background: #f6fafb;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px;
}

.kanban-col h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.task-chip {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-2);
  border-radius: 8px;
  padding: 7px;
  font-size: 11px;
  background: #fff;
  margin-bottom: 6px;
}

.ai-chat-history {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fcfd;
  padding: 8px;
  margin-bottom: 10px;
}

.ai-chat-item {
  margin-bottom: 8px;
}

.ai-chat-item:last-child {
  margin-bottom: 0;
}

.ai-chat-msg {
  margin-top: 6px;
}

.gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gate-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.feature-list {
  margin: 0;
  padding-left: 18px;
  color: var(--sub);
  font-size: 12px;
  display: grid;
  gap: 5px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #102a43;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  max-width: min(420px, calc(100vw - 24px));
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.page-guide {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(560px, calc(100vw - 22px));
  max-height: min(74vh, 760px);
  overflow: auto;
  z-index: 1100;
  border-radius: 14px;
  border: 1px solid rgba(219, 247, 248, 0.38);
  background: linear-gradient(180deg, rgba(4, 60, 77, 0.98) 0%, rgba(7, 92, 102, 0.98) 55%, rgba(10, 123, 130, 0.98) 100%);
  box-shadow: 0 22px 42px rgba(4, 31, 44, 0.45);
  padding: 16px 16px 12px;
  animation: pageGuideIn 0.24s ease both;
  backdrop-filter: blur(4px);
}

.page-guide-head h3 {
  margin: 0;
  font-size: 22px;
  color: #f2fdff;
  letter-spacing: 0.2px;
}

.page-guide-body {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.78;
  color: rgba(243, 252, 255, 0.98);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.page-guide-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(216, 242, 247, 0.35);
  display: flex;
  justify-content: flex-end;
}

.page-guide-actions .btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(236, 252, 255, 0.68);
  color: #f3fdff;
  font-size: 13px;
  padding: 6px 12px;
}

.page-guide-actions .btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

body.studio-popup-mode .page-guide {
  top: 12px;
  right: 12px;
  width: min(620px, calc(100vw - 16px));
  max-height: min(75vh, 820px);
}

@keyframes pageGuideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 220px 1fr;
  }

  .ai-panel {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .studio-layout-main {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    min-height: auto;
    height: auto;
    max-height: none;
  }

  .studio-hero h2 {
    font-size: 30px;
  }

  .studio-chat-head h3 {
    font-size: 28px;
  }

  .studio-left-top {
    grid-column: 1;
    grid-row: 1;
  }

  .studio-right-top {
    grid-column: 2;
    grid-row: 1;
  }

  .studio-center {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 460px;
    height: auto;
    max-height: none;
  }

  .studio-left-bottom {
    grid-column: 1;
    grid-row: 3;
  }

  .studio-right-bottom {
    grid-column: 2;
    grid-row: 3;
  }

  .flow-timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flow-time-item::after {
    display: none;
  }

  .project-flow-canvas {
    overflow-x: auto;
  }

  .contract-wizard-grid {
    grid-template-columns: 1fr;
  }

  .contract-flow-track {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1460px) {
  .split-home {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 320px;
  }

  .main-area {
    padding: 12px;
  }

  .modal-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    max-height: calc(88vh - 70px);
  }

  .modal-list {
    max-height: 220px;
  }

  .studio-hero {
    flex-direction: column;
  }

  .studio-hero h2 {
    font-size: 24px;
  }

  .studio-chat-head h3 {
    font-size: 22px;
  }

  .studio-layout-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    max-height: none;
  }

  .studio-left-top,
  .studio-right-top,
  .studio-center,
  .studio-left-bottom,
  .studio-right-bottom {
    grid-column: 1;
    grid-row: auto;
  }

  .studio-center {
    min-height: 420px;
    height: auto;
    max-height: none;
  }

  .contract-flow-track {
    grid-template-columns: 1fr;
  }

  .flow-timeline {
    grid-template-columns: 1fr;
  }

  .flow-time-item::after {
    display: none;
  }

  .grid-4,
  .grid-3,
  .grid-2,
  .split,
  .gate-grid,
  .kanban {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    gap: 8px;
  }

  .page-guide {
    top: 8px;
    right: 8px;
    width: calc(100vw - 16px);
    max-height: min(82vh, 820px);
    padding: 12px;
  }

  .page-guide-head h3 {
    font-size: 20px;
  }

  .page-guide-body {
    font-size: 14px;
    line-height: 1.72;
  }
}
