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

:root {
  --bg: #0b1020;
  --surface: #121a2f;
  --surface-2: #1a2542;
  --surface-3: #223156;
  --border: #30436e;
  --text: #e7eefc;
  --text-dim: #98a8cc;
  --accent: #f97316;
  --accent-soft: #fb923c33;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --radius: 10px;
  --radius-lg: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(249, 115, 22, .16), transparent 24rem),
    radial-gradient(circle at top left, rgba(59, 130, 246, .12), transparent 20rem),
    linear-gradient(180deg, #09101e, #0c1325 40%, #0b1020);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: #ffb067; text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: "JetBrains Mono", "Fira Code", monospace; }

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 24px;
  background: rgba(9, 16, 30, .84);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.nav-brand { color: var(--text); font-weight: 700; letter-spacing: .03em; }
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-links a { color: var(--text-dim); font-size: 13px; }
.nav-links a.active, .nav-links a:hover { color: var(--text); text-decoration: none; }

.main { max-width: 1320px; margin: 0 auto; padding: 28px 24px 72px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-decoration: none !important;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: #ea580c; }
.btn-ghost { background: rgba(255, 255, 255, .03); border-color: rgba(255, 255, 255, .08); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; }

.flash-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash { padding: 12px 14px; border-radius: var(--radius); border: 1px solid; }
.flash-success { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .3); color: #7df2a5; }
.flash-error { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); color: #ff9d9d; }
.flash-warning { background: rgba(234, 179, 8, .12); border-color: rgba(234, 179, 8, .35); color: #ffd86e; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 30px; line-height: 1.1; }
.page-sub { color: var(--text-dim); margin-top: 6px; }
.header-actions, .meta-row, .panel-actions, .form-actions, .filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.filter-bar { margin-bottom: 18px; }
.filter-search { max-width: 260px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.project-card,
.card,
.form-card,
.split-panel,
.preview-item,
.auth-card {
  background: linear-gradient(180deg, rgba(25, 37, 66, .94), rgba(17, 24, 43, .94));
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: var(--shadow);
}

.project-card {
  display: block;
  padding: 16px;
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none !important;
}
.project-card:hover { border-color: rgba(249, 115, 22, .4); }
.project-card-urgent { border-color: rgba(234, 179, 8, .45); }
.project-card-header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.project-name { font-weight: 700; }
.project-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; color: var(--text-dim); font-size: 12px; }
.project-card-workers, .project-card-tags, .tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }

.status-badge,
.worker-chip,
.tag,
.artifact-type,
.approval-decision,
.worker-tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
}

.status-badge { text-transform: uppercase; letter-spacing: .03em; }
.status-draft-planned { background: rgba(148, 163, 184, .18); color: #d2d9eb; }
.status-plan-pending-approval { background: rgba(234, 179, 8, .18); color: #ffe082; }
.status-approved { background: rgba(34, 197, 94, .18); color: #8af0a6; }
.status-implementing { background: rgba(59, 130, 246, .18); color: #95c7ff; }
.status-preview-review { background: rgba(217, 70, 239, .18); color: #f4abff; }
.status-done { background: rgba(34, 197, 94, .22); color: #8af0a6; }
.status-blocked, .status-rejected { background: rgba(239, 68, 68, .18); color: #ff9f9f; }
.status-changes-requested { background: rgba(249, 115, 22, .18); color: #ffbf8c; }

.worker-chip { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); color: var(--text-dim); }
.tag {
  background: color-mix(in srgb, var(--tag-color, #6366f1) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag-color, #6366f1) 50%, transparent);
  color: #eef3ff;
}
.tag::before, .tag-dot {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--tag-color, #6366f1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tag-color, #6366f1) 20%, transparent);
}
.tag-remove { border: none; cursor: pointer; }

.meta-template, .meta-date, .panel-hint, .empty-text { color: var(--text-dim); font-size: 12px; }

.form-card, .card { border-radius: var(--radius-lg); padding: 22px; }
.form-card { max-width: 920px; }
.form-section { margin-bottom: 24px; }
.section-title, .approval-form h3, .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #d7e1fb;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
}

.field-label { display: block; margin-bottom: 6px; font-weight: 600; }
.field-hint { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.required { color: #ff8d8d; }
.field-input, .field-select, .field-textarea {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font: inherit;
  outline: none;
}
.field-input:focus, .field-select:focus, .field-textarea:focus { border-color: rgba(249, 115, 22, .55); }
.field-textarea { resize: vertical; }
.field-color { width: 60px; min-width: 60px; padding: 4px; }

.radio-group { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; }
.radio-label { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

.template-grid, .worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.template-card, .worker-card, .tag-option {
  display: block;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
  padding: 14px;
  cursor: pointer;
}
.template-card:has(input:checked),
.worker-card:has(input:checked),
.tag-option:has(input:checked) { border-color: rgba(249, 115, 22, .55); background: rgba(249, 115, 22, .08); }
.template-card input, .worker-card input, .tag-option input { display: none; }
.template-name, .worker-name { font-weight: 700; margin-bottom: 6px; }
.template-version, .template-desc { font-size: 12px; color: var(--text-dim); }
.tier-premium { background: rgba(249, 115, 22, .16); color: #ffc18d; }
.tier-mini { background: rgba(59, 130, 246, .16); color: #9fd2ff; }
.skill-card-disabled { opacity: .62; }
.tag-pick-display { pointer-events: none; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; }
.detail-grid-chat { align-items: start; }
.detail-group { margin-top: 18px; }
.detail-group h3 { margin-bottom: 8px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.tag-assignment { display: flex; flex-direction: column; gap: 10px; }
.tag-assign-select { max-width: 220px; margin-bottom: 0; }

.info-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.info-list dt { color: var(--text-dim); }
.path { word-break: break-all; color: var(--text-dim); }

.constraints-block { margin-top: 16px; }
.constraints-block h3 { margin-bottom: 8px; font-size: 12px; color: var(--text-dim); }
.constraints-text,
.log-block,
.plan-content {
  white-space: pre-wrap;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, .22);
  border: 1px solid rgba(255, 255, 255, .06);
}
.constraints-reminder {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(234, 179, 8, .28);
  background: rgba(234, 179, 8, .08);
  color: #ffe6a0;
}

.worker-list, .artifact-list, .approval-list, .preview-list { display: flex; flex-direction: column; gap: 8px; }
.worker-item, .artifact-item, .approval-item, .preview-item { border-radius: 14px; }
.artifact-item, .preview-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.artifact-name { color: #ffb067; }
.artifact-type { background: rgba(255, 255, 255, .08); color: var(--text-dim); }
.artifact-version { color: var(--text-dim); font-size: 12px; }
.approval-item { padding: 12px; border: 1px solid rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .03); }
.approval-header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.approval-date, .approval-note { color: var(--text-dim); font-size: 12px; }
.approval-date { margin-left: auto; }
.approval-note { margin-top: 6px; }
.approval-table { width: 100%; border-collapse: collapse; }
.approval-table th, .approval-table td { padding: 12px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.approval-table th { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }

.split-view {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 16px;
  min-height: 620px;
}
.split-panel { display: flex; flex-direction: column; border-radius: var(--radius-lg); overflow: hidden; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
}
.panel-header h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.plan-textarea, .plan-preview, .file-view { flex: 1; padding: 16px; }
.plan-textarea, .file-editor {
  height: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: "JetBrains Mono", monospace;
}
.file-content { white-space: pre-wrap; line-height: 1.7; }
.file-binary { padding: 24px; color: var(--text-dim); }

.chat-panel, .plan-chat-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-card { min-height: 620px; }
.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px 0;
}
.chat-model-select {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text-dim);
  font-size: 12px;
}
.chat-model-select select {
  min-width: 220px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
}
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-empty { color: var(--text-dim); font-style: italic; }
.chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 16px;
  white-space: pre-wrap;
}
.chat-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: white;
}
.chat-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}
.chat-typing { color: var(--text-dim); }
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.chat-input { margin: 0; min-height: 96px; }
.capture-row { padding: 0 16px 16px; }

.tag-create-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tag-table .field-input { margin-bottom: 0; }
.tag-color-cell { display: flex; align-items: center; gap: 10px; }
.tag-row-actions { display: flex; justify-content: flex-end; gap: 8px; }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: min(380px, 92vw); border-radius: 20px; padding: 32px; }
.auth-title { font-size: 24px; text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--text-dim); margin-bottom: 22px; }

.empty-state { text-align: center; padding: 54px 24px; color: var(--text-dim); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 999px; }

@media (max-width: 980px) {
  .detail-grid,
  .split-view { grid-template-columns: 1fr; }
  .chat-card { min-height: 420px; }
}

@media (max-width: 640px) {
  .main { padding: 18px 14px 52px; }
  .navbar { padding: 0 14px; height: auto; min-height: 58px; flex-wrap: wrap; gap: 10px; }
  .nav-links { width: 100%; justify-content: space-between; padding-bottom: 10px; }
  .page-header { flex-direction: column; }
  .chat-input-row { flex-direction: column; }
  .chat-model-select { width: 100%; }
  .chat-model-select select { min-width: 0; width: 100%; }
}
