:root {
  --bg: #1f2128;
  --bg-soft: #252830;
  --panel: #2a2d36;
  --panel-2: #2f323b;
  --line: #3a3e48;
  --line-soft: #343841;
  --text: #ebedf3;
  --muted: #a6acbb;
  --accent: #7fa7ff;
  --accent-soft: #22304a;
  --danger: #d87876;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(85% 130% at 12% -14%, rgba(93, 79, 149, 0.38), transparent 60%),
    radial-gradient(70% 100% at 100% 0%, rgba(65, 85, 133, 0.32), transparent 62%),
    #1f2128;
}

.shell {
  min-height: 100vh;
  position: relative;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 11px;
  color: var(--muted);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
.route-hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(23, 25, 31, 0.8);
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(133, 169, 255, 0.3);
  border-color: #6888ce;
}

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

button {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  color: #f6f8ff;
  background: linear-gradient(120deg, #637ec5, #4f67a9);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

button.danger {
  background: linear-gradient(130deg, #b25f5c, #934b49);
}

button.block {
  width: 100%;
}

.form-error {
  margin: 0;
  color: #f0a19f;
  font-size: 13px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: min(420px, 100%);
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(33, 36, 44, 0.92);
  padding: 24px;
  display: grid;
  gap: 10px;
}

.login-card h1 {
  font-size: 34px;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.app-view {
  min-height: 100vh;
}

.app-frame {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.side-nav {
  border-right: 1px solid var(--line-soft);
  background: rgba(19, 21, 27, 0.84);
  padding: 16px 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.brand-block {
  padding: 6px 8px;
}

.brand-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 33px;
  line-height: 1;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.main-nav {
  display: grid;
  gap: 6px;
  align-content: start;
}

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #e3e6ef;
  text-align: left;
  padding: 9px 10px;
}

.nav-item:hover {
  border-color: var(--line);
  background: rgba(44, 47, 58, 0.45);
}

.nav-item.active {
  border-color: var(--line);
  background: #323643;
}

.side-footer {
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.main-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
}

.topbar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(39, 42, 51, 0.84);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.topbar h2 {
  font-size: 23px;
}

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

.user-chip {
  display: inline-flex;
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid #3f5888;
  border-radius: 999px;
  color: #c3d6ff;
  padding: 4px 9px;
  font-size: 12px;
}

.route {
  display: none;
  min-height: 0;
}

.route.active {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.route-hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(40, 43, 52, 0.7);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.route-hero h1 {
  font-size: clamp(34px, 4.4vw, 58px);
  line-height: 1.06;
}

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

.suggestion-chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 12px;
}

.suggestion-chip:hover {
  background: #343844;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.task-list-panel,
.task-detail-panel,
.composer-card,
.agent-thread,
.library-toolbar,
.library-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(41, 44, 53, 0.82);
}

.task-list-panel,
.task-detail-panel {
  padding: 12px;
  display: grid;
  gap: 10px;
}

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

.task-list {
  display: grid;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 2px;
}

.task-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(26, 29, 36, 0.75);
  color: var(--text);
  text-align: left;
  padding: 9px;
  display: grid;
  gap: 5px;
}

.task-item.active {
  border-color: #6485c7;
  background: #313848;
}

.task-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.task-id {
  font-size: 11px;
  color: var(--muted);
  font-family: "IBM Plex Mono", Menlo, monospace;
}

.task-status {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  font-weight: 600;
  color: #b8c1d8;
}

.task-status.running,
.task-status.canceling,
.task-status.queued {
  color: #e7b773;
}

.task-status.completed {
  color: #8bdaaa;
}

.task-status.failed,
.task-status.canceled {
  color: var(--danger);
}

.task-preview {
  margin: 0;
  color: #d5d9e6;
  line-height: 1.4;
  font-size: 12px;
}

.task-time {
  color: var(--muted);
  font-size: 11px;
}

.task-meta {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(20, 22, 29, 0.66);
  color: var(--muted);
  padding: 8px 9px;
  font-size: 12px;
}

.detail-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  display: grid;
  gap: 8px;
  min-height: 120px;
  background: rgba(20, 22, 29, 0.66);
}

.detail-block h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.detail-pre,
.log-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
}

.detail-pre {
  max-height: 210px;
  overflow: auto;
}

.log-list {
  display: grid;
  gap: 7px;
  max-height: 250px;
  overflow: auto;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px;
  display: grid;
  gap: 4px;
  background: rgba(35, 38, 45, 0.72);
}

.log-level {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 2px 8px;
  background: #304058;
  color: #bfd4ff;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
}

.log-level.error {
  background: #593535;
  color: #f0abab;
}

.log-time {
  font-size: 11px;
  color: var(--muted);
}

.agent-thread {
  padding: 16px;
  overflow: auto;
  max-height: calc(100vh - 292px);
  display: grid;
  gap: 16px;
  align-content: start;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  max-width: min(740px, 100%);
}

.bubble.user {
  justify-self: end;
  background: #37435a;
}

.bubble.assistant {
  justify-self: start;
  background: #2d313b;
}

.bubble p {
  margin: 0;
  line-height: 1.45;
}

.library-toolbar {
  padding: 10px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  align-content: start;
  overflow: auto;
  max-height: calc(100vh - 310px);
}

.library-card {
  padding: 11px;
  display: grid;
  gap: 9px;
}

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

.library-agent {
  font-size: 11px;
  color: var(--muted);
  font-family: "IBM Plex Mono", Menlo, monospace;
}

.library-status {
  font-size: 11px;
  color: #bfd4ff;
  text-transform: uppercase;
}

.library-title {
  font-size: 15px;
  line-height: 1.35;
}

.library-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  min-height: 3.2em;
}

.composer-card {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.composer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 14, 0.72);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 16px;
}

.search-panel {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #272b35;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.search-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.search-results {
  max-height: min(62vh, 560px);
  overflow: auto;
  display: grid;
  gap: 8px;
}

.search-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(31, 34, 42, 0.88);
  color: var(--text);
  text-align: left;
  padding: 9px;
  display: grid;
  gap: 6px;
}

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

.search-id {
  font-family: "IBM Plex Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}

.search-time {
  font-size: 11px;
  color: var(--muted);
}

.search-preview {
  margin: 0;
  color: #d6daea;
  font-size: 12px;
  line-height: 1.4;
}

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

  .side-nav {
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

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

  .task-list {
    max-height: 30vh;
  }

  .agent-thread,
  .library-grid {
    max-height: none;
  }
}

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

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

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search-head {
    grid-template-columns: 1fr;
  }
}
