:root {
  --bg: #070b14;
  --surface: #0e1523;
  --surface-2: #121c2d;
  --text: #f5f7fb;
  --text-muted: #98a4b8;
  --primary: #77e3ff;
  --secondary: #7e8bff;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(119, 227, 255, 0.35);
  --glow: rgba(119, 227, 255, 0.18);
  --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.35);
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Sora", "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 480px at 50% -12%, rgba(126, 139, 255, 0.18), transparent 62%),
    radial-gradient(860px 360px at 12% 14%, rgba(119, 227, 255, 0.11), transparent 60%),
    var(--bg);
}

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(18, 28, 45, 0.8), rgba(14, 21, 35, 0.78));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

h1 {
  margin: 0 0 7px;
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  font-weight: 720;
  letter-spacing: 0.02em;
}

p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.96rem;
}

.phase-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(18, 28, 45, 0.75);
  min-width: fit-content;
}

.phase-label {
  color: var(--text-muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.phase-gather {
  color: #b7e9ff;
  background: rgba(23, 49, 70, 0.7);
}

.phase-preview {
  color: #fff1b2;
  background: rgba(68, 57, 20, 0.7);
}

.phase-generate {
  color: #c5ffea;
  background: rgba(18, 61, 46, 0.7);
}

.phase-done {
  color: #e8ddff;
  background: rgba(47, 30, 72, 0.72);
}

.workspace {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(18, 28, 45, 0.9), rgba(14, 21, 35, 0.9));
  padding: 18px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.workspace::before {
  content: "";
  position: absolute;
  inset: -120px auto auto -120px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
  pointer-events: none;
}

.project-row {
  display: grid;
  gap: 7px;
  max-width: 360px;
  margin-bottom: 14px;
}

label {
  color: var(--text-muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

input,
textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(11, 19, 32, 0.88);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

input::placeholder,
textarea::placeholder {
  color: #7f8da3;
}

input:focus,
textarea:focus {
  border-color: var(--border-hover);
  box-shadow: 0 0 0 3px rgba(119, 227, 255, 0.18);
}

button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 640;
  color: #06131a;
  background: linear-gradient(120deg, var(--primary), #9debff);
  cursor: pointer;
  transition: transform 0.13s ease, box-shadow 0.13s ease, border-color 0.13s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(119, 227, 255, 0.2);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-btn {
  color: var(--text);
  border-color: var(--border);
  background: linear-gradient(130deg, rgba(27, 42, 60, 0.95), rgba(21, 34, 51, 0.95));
}

.secondary-btn:hover {
  border-color: var(--border-hover);
}

.danger-btn {
  color: #ffdfe2;
  border-color: rgba(255, 128, 128, 0.24);
  background: linear-gradient(120deg, rgba(86, 27, 40, 0.95), rgba(122, 43, 54, 0.95));
}

.danger-btn:hover {
  border-color: rgba(255, 128, 128, 0.44);
  box-shadow: 0 8px 20px rgba(255, 130, 130, 0.18);
}

.messages {
  position: relative;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 420px;
  max-height: 60vh;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(9, 16, 28, 0.96), rgba(7, 13, 22, 0.97));
}

.loading-overlay {
  position: sticky;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
  pointer-events: none;
}

.loading-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-hover);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--text);
  background: rgba(12, 22, 37, 0.92);
  box-shadow: 0 10px 26px var(--glow);
  backdrop-filter: blur(8px);
}

.loading-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(119, 227, 255, 0.26);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: var(--text-muted);
  font-size: 0.86rem;
  letter-spacing: 0.01em;
}

.messages::-webkit-scrollbar {
  width: 10px;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(152, 164, 184, 0.3);
  border-radius: 999px;
}

.msg {
  padding: 11px 13px;
  margin: 11px 0;
  border-radius: var(--radius-sm);
  max-width: 88%;
  line-height: 1.5;
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.msg.user {
  margin-left: auto;
  color: #0a1924;
  border-color: rgba(119, 227, 255, 0.38);
  background: linear-gradient(125deg, #7be6ff, #89d9ff);
}

.msg.assistant {
  margin-right: auto;
  color: var(--text);
  background: linear-gradient(150deg, rgba(19, 31, 49, 0.95), rgba(17, 29, 44, 0.95));
}

.quick-action-wrap {
  display: flex;
  justify-content: flex-start;
  margin: 6px 0 12px;
}

.quick-yes-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-hover);
  color: #06131a;
  background: linear-gradient(120deg, var(--primary), #9debff);
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(119, 227, 255, 0.18);
}

.quick-yes-btn:hover {
  box-shadow: 0 10px 20px rgba(119, 227, 255, 0.25);
}

.status {
  background: linear-gradient(150deg, rgba(18, 36, 58, 0.95), rgba(16, 28, 44, 0.95));
}

.reasoning {
  border-color: rgba(126, 139, 255, 0.3);
  background: linear-gradient(150deg, rgba(31, 41, 69, 0.95), rgba(22, 34, 54, 0.95));
}

.error {
  border-color: rgba(255, 140, 140, 0.3);
  background: linear-gradient(145deg, rgba(76, 22, 31, 0.95), rgba(56, 18, 25, 0.95));
}

.success {
  border-color: rgba(119, 227, 255, 0.34);
  background: linear-gradient(145deg, rgba(17, 57, 57, 0.95), rgba(13, 47, 53, 0.95));
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

.composer textarea {
  min-height: 74px;
  resize: vertical;
}

.assistant-pre {
  margin-top: 10px;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(126, 139, 255, 0.3);
  background: rgba(10, 16, 29, 0.95);
  overflow-x: auto;
  color: #d8e7ff;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre;
}

a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.13s ease;
}

a:hover {
  border-color: rgba(119, 227, 255, 0.6);
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-row {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .messages {
    min-height: 360px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .workspace,
  .topbar {
    border-radius: 18px;
    padding: 14px;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .msg {
    max-width: 100%;
  }
}
