:root {
  color-scheme: dark;
  --bg: #08090f;
  --sidebar: #090a10;
  --surface: #0f1117;
  --surface-soft: #151821;
  --surface-hover: #191d27;
  --ink: #f7f8fb;
  --muted: #9aa3b2;
  --quiet: #687080;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #f8fafc;
  --success: #7ee787;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

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

.landing {
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.landing-inner {
  width: min(38rem, 100%);
  text-align: center;
}

.landing-kicker {
  margin: 0 auto 0.9rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
  text-transform: uppercase;
}

.landing h1 {
  margin: 0;
  font-size: clamp(3.25rem, 10vw, 6.5rem);
  font-weight: 720;
  line-height: 0.92;
}

.landing-inner > p:not(.landing-kicker) {
  max-width: 32rem;
  margin: 1.2rem auto 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.error-text {
  color: #ff9b9b;
  font-size: 0.92rem;
}

.modal-error {
  margin: 0 0 0.85rem;
}

.landing-actions {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 1.8rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  padding: 0 0.95rem;
}

.button:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.045);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #07090d;
}

.button.primary:hover {
  background: #ffffff;
}

.button.small {
  min-height: 2.1rem;
  border-radius: 7px;
  font-size: 0.84rem;
  padding: 0 0.7rem;
}

.button:disabled {
  cursor: default;
  opacity: 0.55;
}

.workspace {
  display: grid;
  grid-template-columns: 17.5rem minmax(0, 1fr);
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--sidebar) 94%, transparent);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.05rem;
  border-bottom: 1px solid var(--line);
}

.brand-copy strong,
.brand-copy span {
  display: block;
}

.brand-copy strong {
  font-size: 0.9rem;
  font-weight: 650;
}

.brand-copy span {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.thread-list {
  display: grid;
  align-content: start;
  gap: 0.45rem;
  padding: 0.7rem;
}

.workspace-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.65rem 0.7rem 0;
}

.workspace-tab {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
  padding: 0.48rem 0.42rem;
  text-align: left;
}

.workspace-tab:hover,
.workspace-tab.active {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
}

.workspace-tab span {
  overflow: hidden;
  font-size: 0.68rem;
  font-weight: 700;
  text-overflow: ellipsis;
}

.workspace-tab strong {
  font-size: 0.76rem;
}

.sidebar-note {
  color: var(--quiet);
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 0.7rem 0.78rem;
}

.thread-button {
  position: relative;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0.72rem 0.78rem 0.78rem;
  text-align: left;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.thread-button:hover {
  background: rgba(255, 255, 255, 0.035);
  transform: translateY(-1px);
}

.thread-button.active {
  border-color: rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.thread-button.active::before {
  content: "";
  position: absolute;
  top: 0.72rem;
  bottom: 0.72rem;
  left: -0.72rem;
  width: 0.18rem;
  border-radius: 999px;
  background: var(--accent);
}

.thread-status {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 1.3rem;
  margin-bottom: 0.48rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--quiet);
  font-size: 0.66rem;
  font-weight: 650;
  line-height: 1;
  padding: 0 0.48rem;
}

.thread-status.approved {
  border-color: rgba(126, 231, 135, 0.22);
  background: rgba(126, 231, 135, 0.06);
  color: var(--success);
}

.thread-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.thread-title strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fit-score {
  color: var(--success);
  font-size: 0.73rem;
  font-weight: 700;
}

.thread-button p {
  overflow: hidden;
  margin: 0.28rem 0 0;
  color: var(--quiet);
  font-size: 0.74rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
}

.agent-card-link {
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 650;
  text-decoration: none;
}

.agent-card-link:hover {
  color: var(--ink);
}

.loading-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.main-panel {
  min-width: 0;
  padding: 1rem 1.4rem 3rem;
}

.workspace-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.75rem;
  max-width: 60rem;
  margin: 0 auto 0.9rem;
}

.workspace-top h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
}

.workspace-top p {
  margin: 0.2rem 0 0;
  color: var(--quiet);
  font-size: 0.78rem;
}

.match-review {
  max-width: 60rem;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 17, 23, 0.78);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.match-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  padding: 1.45rem 1.5rem 1.35rem;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin: 0 0 0.65rem;
  color: var(--success);
  font-size: 0.74rem;
  font-weight: 700;
}

.match-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 3.05rem);
  font-weight: 720;
  line-height: 1.02;
}

.match-header p:not(.kicker) {
  max-width: 40rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.approval-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.inline-actions {
  margin-top: 1rem;
}

.review-section {
  display: grid;
  grid-template-columns: 8.25rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.review-section:last-child {
  border-bottom: 0;
}

.review-section h3 {
  margin: 0;
  color: var(--quiet);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.review-section p {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.6;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem 1.5rem;
}

.compact-grid div {
  min-width: 0;
}

.compact-grid span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--quiet);
  font-size: 0.72rem;
}

.compact-grid strong,
.compact-grid a {
  display: block;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 620;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.stack-list {
  display: grid;
  gap: 0.85rem;
}

.stack-item {
  display: grid;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 0.85rem;
}

.stack-item strong {
  font-size: 0.92rem;
}

.stack-item p {
  color: var(--muted);
  font-size: 0.88rem;
}

.stack-item span {
  color: var(--quiet);
  font-size: 0.74rem;
  font-weight: 650;
}

.stack-item .button {
  justify-self: start;
  margin-top: 0.25rem;
}

.credential-panel {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.credential-row {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.credential-row span {
  color: var(--quiet);
  font-size: 0.74rem;
  font-weight: 700;
}

.credential-row code {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--ink);
  font: 0.78rem/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 0.5rem 0.6rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plain-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  color: var(--ink);
  list-style: none;
}

.plain-list li {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.ordered-list {
  counter-reset: protocol-step;
}

.ordered-list li {
  counter-increment: protocol-step;
  position: relative;
  padding-left: 1.7rem;
}

.ordered-list li::before {
  content: counter(protocol-step);
  position: absolute;
  left: 0;
  top: 0.08rem;
  display: grid;
  place-items: center;
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  font-size: 0.62rem;
  font-weight: 700;
}

.conversation {
  display: grid;
  gap: 0.85rem;
}

.message {
  max-width: 44rem;
}

.message strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--quiet);
  font-size: 0.7rem;
  font-weight: 700;
}

.message p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.58;
}

.message.mine p {
  color: var(--ink);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 9, 0.82);
  padding: 1rem;
}

.modal {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(39rem, 100%);
  max-height: min(44rem, calc(100vh - 2rem));
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.compact-modal {
  width: min(28rem, 100%);
}

.modal-header,
.modal-footer {
  padding: 1rem;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  border-top: 1px solid var(--line);
}

.modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-content: flex-end;
}

.modal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.step-dots {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.85rem;
}

.step-dot {
  height: 0.22rem;
  flex: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.step-dot.active {
  background: var(--ink);
}

.modal-body {
  overflow-y: auto;
  padding: 1rem;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: 0;
  padding: 0.75rem 0.8rem;
}

.field select {
  color-scheme: dark;
  padding-right: 2.6rem;
}

.field textarea {
  min-height: 6rem;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--line-strong);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 3.1rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.icon-button:hover {
  color: var(--ink);
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.65rem;
  width: 2.1rem;
  height: 2.1rem;
  transform: translateY(-50%);
}

.password-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.voice-control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.45rem;
}

.voice-button {
  width: 2.45rem;
  padding: 0;
}

.voice-button.listening {
  border-color: rgba(248, 250, 252, 0.6);
  background: rgba(255, 255, 255, 0.08);
}

.voice-button svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.voice-status {
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.check-card {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
  padding: 0.65rem;
}

.check-card input {
  width: 1rem;
  height: 1rem;
  margin-top: 0.08rem;
  accent-color: var(--ink);
}

.check-card span {
  font-size: 0.82rem;
  line-height: 1.35;
}

.empty-state {
  display: grid;
  min-height: calc(100vh - 6rem);
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  color: var(--ink);
}

.empty-state p {
  max-width: 30rem;
  margin: 0.75rem 0 0;
  line-height: 1.55;
}

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

  .sidebar {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .thread-list {
    width: 100%;
    max-width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: minmax(13rem, 17rem);
    overflow-x: auto;
  }

  .sidebar-footer {
    display: none;
  }

  .match-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .landing-actions,
  .modal-footer,
  .approval-actions {
    flex-direction: column;
  }

  .landing-actions .button,
  .modal-footer .button,
  .approval-actions .button {
    width: 100%;
  }

  .modal-footer-actions {
    width: 100%;
  }

  .modal-footer-actions .voice-button {
    flex: 0 0 2.45rem;
    width: 2.45rem;
  }

  .main-panel {
    padding: 0.85rem 1rem 2rem;
  }

  .workspace-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .review-section,
  .compact-grid,
  .check-grid,
  .credential-row {
    grid-template-columns: 1fr;
  }
}
