/* Parley – "workbench" theme
   Warm graphite, one amber accent, IBM Plex Sans for reading,
   IBM Plex Mono for machine values (models, tools, code).
   The chat is a transcript: a fixed role column on the left, text on the right. */

@font-face {
  font-family: "Plex Sans";
  src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("../fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Surfaces: neutral-warm graphite, no blue cast */
  --bg: #161616;
  --panel: #1c1c1b;
  --raised: #232321;
  --hover: #2a2a27;
  --line: #31302d;
  --line-soft: #262624;

  /* Text */
  --text: #e8e6e1;
  --text-muted: #a29e96;
  --text-faint: #75726b;

  /* One accent */
  --amber: #e0a040;
  --amber-strong: #f0b555;
  --amber-ink: #1d1404;
  --amber-wash: rgba(224, 160, 64, 0.1);

  --danger: #e2694f;
  --danger-wash: rgba(226, 105, 79, 0.1);
  --ok: #9fbc7f;
  --ok-wash: rgba(159, 188, 127, 0.1);

  --radius: 3px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --sidebar-duration: 0.24s;
  --sidebar-width: 268px;
  --gutter: 112px;
  --measure: 720px;

  --font-sans: "Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

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

a {
  color: var(--amber);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--amber-strong);
}

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

code,
pre,
textarea.code {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

::selection {
  background: rgba(224, 160, 64, 0.32);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #3a3935;
  border: 3px solid var(--bg);
  border-radius: 0;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-caret {
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  background: var(--amber);
  transform: translateY(1px);
}

/* ---------- Boot & loading ---------- */

.boot-screen,
.loading-state {
  height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.loading-state {
  height: 100%;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.btn-primary {
  background: var(--amber);
  color: var(--amber-ink);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--amber-strong);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
  border-color: #3d3c38;
}

.btn-danger {
  background: transparent;
  border-color: rgba(226, 105, 79, 0.45);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-wash);
}

.btn-block {
  width: 100%;
}

.btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background-color 0.12s, color 0.12s;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn.danger:hover {
  color: var(--danger);
  background: var(--danger-wash);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.icon-btn.small {
  width: 26px;
  height: 26px;
}

.icon-btn.small svg {
  width: 14px;
  height: 14px;
}

.icon-btn.tiny {
  width: 24px;
  height: 24px;
}

.icon-btn.tiny svg {
  width: 13px;
  height: 13px;
}

/* ---------- Form controls ---------- */

.input,
.select,
.textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: #403f3a;
}

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

.input:disabled {
  color: var(--text-muted);
  background: transparent;
  border-style: dashed;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

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

.textarea.code {
  font-size: 12.5px;
  line-height: 1.55;
  min-height: 74px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: 1fr 1fr;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.form-hint {
  font-size: 12.5px;
  color: var(--text-faint);
  margin: 2px 0 0;
}

.form-error {
  border-left: 2px solid var(--danger);
  background: var(--danger-wash);
  color: #f2b8a9;
  padding: 8px 12px;
  font-size: 13px;
  margin: 0 0 14px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  vertical-align: middle;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: background-color 0.12s, border-color 0.12s;
}

.switch span::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 2px;
  top: 2px;
  background: var(--text-faint);
  border-radius: 1px;
  transition: transform 0.12s, background-color 0.12s;
}

.switch input:checked + span {
  border-color: var(--amber);
  background: var(--amber-wash);
}

.switch input:checked + span::before {
  transform: translateX(16px);
  background: var(--amber);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.badge.ok {
  color: var(--ok);
  border-color: rgba(159, 188, 127, 0.4);
}

.badge.warn {
  color: var(--amber);
  border-color: rgba(224, 160, 64, 0.4);
}

.badge.error {
  color: var(--danger);
  border-color: rgba(226, 105, 79, 0.45);
}

/* ---------- Toggles in dialogs and forms ---------- */

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 13.5px;
}

.toggle-row + .toggle-row {
  border-top: 1px solid var(--line-soft);
}

.form-grid.two > .toggle-row + .toggle-row {
  border-top: none;
}

.toggle-row .switch {
  margin-top: 1px;
  flex-shrink: 0;
}

.toggle-row.disabled {
  cursor: default;
  color: var(--text-faint);
}

.toggle-text {
  display: grid;
  gap: 1px;
}

.toggle-text small {
  font-size: 12px;
  color: var(--text-faint);
}

.tools-form .settings-section {
  margin-bottom: 18px;
}

.dialog-hint {
  margin: -10px 0 16px;
}

.template-hint {
  margin-top: -6px;
}

/* ---------- Toasts ---------- */

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  background: var(--raised);
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--ok);
}

/* ---------- Modal & dialogs ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 9, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  width: min(640px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-wide {
  width: min(880px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 52px;
  padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-tabs {
  display: flex;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-tab {
  padding: 10px 0 9px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.modal-tab:hover {
  color: var(--text);
}

.modal-tab.active {
  color: var(--text);
  border-bottom-color: var(--amber);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.dialog {
  padding: 22px 22px 18px;
}

.dialog-message {
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.6;
}

.dialog .field {
  margin-bottom: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
