:root {
  --bg: #f3efe5;
  --bg-accent: #e7dcc8;
  --panel: rgba(255, 250, 241, 0.88);
  --panel-border: rgba(83, 58, 32, 0.12);
  --text: #24170d;
  --muted: #6f6051;
  --accent: #9e2f12;
  --accent-strong: #7d1f07;
  --ok: #1d6a47;
  --warn: #9a6413;
  --danger: #972222;
  --shadow: 0 20px 60px rgba(66, 38, 14, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(158, 47, 18, 0.14), transparent 28rem),
    radial-gradient(circle at top right, rgba(29, 106, 71, 0.12), transparent 24rem),
    linear-gradient(160deg, var(--bg), #fbf8f2 60%, var(--bg-accent));
}

body.locked {
  overflow: hidden;
}

.login-gate {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(24, 17, 10, 0.48);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.login-gate.visible {
  display: flex;
}

.login-panel {
  width: min(32rem, 100%);
  padding: 1.5rem;
  border-radius: 1.5rem;
  background: rgba(255, 250, 241, 0.96);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0 0.75rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.field input {
  border: 1px solid rgba(83, 58, 32, 0.16);
  border-radius: 0.85rem;
  padding: 0.85rem 0.95rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.82);
}

.app-shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.legal-shell {
  width: min(980px, calc(100vw - 2rem));
}

.hero {
  padding: 1.5rem 1.75rem;
}

.hero-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.8rem;
  color: var(--accent);
}

h1,
h2,
.profile-name {
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
  letter-spacing: 0.02em;
}

h1 {
  margin: 0.25rem 0 0.5rem;
  font-size: clamp(2.6rem, 6vw, 4.8rem);
  line-height: 0.92;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
}

.hero-copy,
.subtle-text,
.profile-meta,
.log-output,
button,
select {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.hero-copy {
  max-width: 42rem;
  font-size: 1.05rem;
  color: var(--muted);
}

.hero-actions,
.card-actions,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 1.25rem;
}

.summary-panel,
.profiles-panel,
.logs-panel {
  min-height: 16rem;
}

.summary-panel,
.profiles-panel {
  animation: rise 320ms ease-out;
}

.logs-panel {
  grid-column: 1 / -1;
  animation: rise 420ms ease-out;
}

.summary-grid,
.gpu-grid,
.profile-grid {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.profile-grid {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.summary-card,
.gpu-card,
.profile-card {
  border: 1px solid rgba(83, 58, 32, 0.1);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.55);
}

.summary-label {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.summary-value,
.profile-name {
  margin: 0;
  font-size: 1.25rem;
}

.profile-description {
  margin: 0.25rem 0 0;
}

.profile-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem 0.75rem;
  margin: 1rem 0 0;
}

.profile-meta dt {
  color: var(--muted);
}

.profile-meta dd {
  margin: 0;
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(111, 96, 81, 0.12);
  color: var(--muted);
}

.status-pill.ready {
  background: rgba(29, 106, 71, 0.14);
  color: var(--ok);
}

.status-pill.partial {
  background: rgba(154, 100, 19, 0.15);
  color: var(--warn);
}

.status-pill.stopped,
.status-pill.muted {
  background: rgba(111, 96, 81, 0.12);
  color: var(--muted);
}

button,
select {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
}

textarea,
input[type="file"],
input[type="number"] {
  border: 1px solid rgba(83, 58, 32, 0.16);
  border-radius: 1rem;
  padding: 0.85rem 0.95rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
}

textarea {
  min-height: 9rem;
  resize: vertical;
}

code {
  font-family: "IBM Plex Mono", monospace;
}

a {
  color: inherit;
}

button {
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.primary-button,
.danger-button,
.ghost-button {
  color: white;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #c04a22);
}

.danger-button {
  background: linear-gradient(135deg, var(--danger), #b74343);
}

.ghost-button {
  background: linear-gradient(135deg, #514235, #715a47);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.log-output {
  min-height: 20rem;
  margin: 1rem 0 0;
  padding: 1rem;
  border-radius: 1rem;
  overflow: auto;
  white-space: pre-wrap;
  background: #211910;
  color: #f0ddbc;
}

.vision-shell {
  width: min(1280px, calc(100vw - 2rem));
}

.chat-shell {
  width: min(1400px, calc(100vw - 2rem));
  padding-top: 1rem;
}

.chat-shell .hero {
  padding-top: 0.85rem;
  padding-bottom: 1.25rem;
}

.vision-grid {
  display: grid;
  grid-template-columns: minmax(18rem, 30rem) 1fr;
  gap: 1rem;
}

.chat-grid {
  display: grid;
  grid-template-columns: minmax(20rem, 28rem) 1.15fr 1fr;
  gap: 1rem;
  align-items: start;
  transition: grid-template-columns 220ms ease;
}

.chat-model-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.8rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(83, 58, 32, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  justify-content: flex-end;
}

.chat-model-status .summary-label {
  margin: 0;
}

.chat-model-status span:not(.summary-label) {
  font-size: 0.95rem;
}

.chat-hero-topline {
  margin-bottom: 0.25rem;
}

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

.chat-title-row h1 {
  margin-bottom: 0;
}

.chat-topline-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chat-vision-link {
  margin-right: 50px;
}

.vision-panel,
.preview-panel,
.result-panel {
  animation: rise 320ms ease-out;
}

.chat-config-panel,
.chat-history-panel {
  animation: rise 320ms ease-out;
}

.chat-config-panel {
  overflow: hidden;
  transition: padding 220ms ease, min-width 220ms ease, width 220ms ease;
  position: sticky;
  top: 1rem;
}

.request-panel-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.request-panel-toggle {
  min-width: 5.75rem;
}

.chat-grid.request-collapsed {
  grid-template-columns: 3.5rem minmax(0, 1.5fr) minmax(0, 1fr);
}

.chat-grid.request-collapsed .chat-config-panel {
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}

.chat-grid.request-collapsed .chat-config-panel .panel-heading {
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.chat-grid.request-collapsed #requestPanelTitle {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 1rem;
}

.chat-grid.request-collapsed .request-panel-controls {
  flex-direction: column;
}

.chat-grid.request-collapsed #chatStatusBadge {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.chat-grid.request-collapsed .chat-form {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(-1rem);
  margin-top: 0;
}

.chat-form {
  transition: max-width 220ms ease, opacity 180ms ease, transform 220ms ease, margin 220ms ease;
}

.preview-panel,
.result-panel {
  min-height: 20rem;
}

.chat-history-panel {
  min-height: 28rem;
}

.chat-history-panel.expanded {
  grid-column: 2 / -1;
}

.result-panel {
  grid-column: auto;
}

.vision-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.chat-form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

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

.chat-form-row-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chat-form-row-bottom {
  align-items: start;
}

.chat-history {
  display: grid;
  gap: 0.9rem;
  max-height: 42rem;
  overflow: auto;
  margin-top: 1rem;
  min-height: 18rem;
}

.chat-request-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.chat-request-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(83, 58, 32, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.chat-request-chip .summary-label {
  margin: 0;
}

.chat-request-chip strong {
  font-size: 0.95rem;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(83, 58, 32, 0.08);
}

.chat-composer-main {
  display: grid;
  gap: 0.85rem;
}

.chat-composer-field textarea {
  min-height: 7.5rem;
}

.chat-attachments {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem 1rem 1rem;
  border: 1px solid rgba(83, 58, 32, 0.12);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.42);
}

.chat-attachments-topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chat-attachments-topline .summary-label {
  margin: 0;
}

.attachment-limits {
  margin: 0;
}

.chat-attachments-body {
  display: grid;
  grid-template-columns: minmax(14rem, 1.3fr) minmax(12rem, 0.9fr);
  gap: 0.8rem;
  align-items: start;
}

.attachment-dropzone {
  display: grid;
  gap: 0.45rem;
  min-height: 100%;
  padding: 0.95rem 1rem;
  border: 1px dashed rgba(83, 58, 32, 0.28);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.58);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.attachment-dropzone:hover,
.attachment-dropzone.active {
  border-color: rgba(158, 47, 18, 0.5);
  background: rgba(255, 247, 240, 0.9);
  transform: translateY(-1px);
}

.attachment-dropzone input[type="file"] {
  display: none;
}

.attachment-dropzone-title {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-weight: 600;
}

.attachment-sidecar {
  display: grid;
  gap: 0.7rem;
  min-height: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(83, 58, 32, 0.09);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.48);
}

.attachment-help {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.attachment-help summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
}

.attachment-help[open] summary {
  margin-bottom: 0.45rem;
}

.attachment-list {
  min-height: 2rem;
}

.attachment-processed-meta {
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(29, 106, 71, 0.16);
  border-radius: 0.85rem;
  background: rgba(29, 106, 71, 0.08);
  color: var(--ok);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 0.92rem;
}

.attachment-items {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(83, 58, 32, 0.1);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.62);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.attachment-name {
  font-weight: 600;
  word-break: break-word;
}

.attachment-meta {
  color: var(--muted);
  white-space: nowrap;
}

.chat-composer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-self: end;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
}

.chat-composer-actions .primary-button,
.chat-composer-actions .compact-button {
  height: 36px;
  padding-top: 0;
  padding-bottom: 0;
}

.compact-button {
  padding: 0.65rem 0.8rem;
  min-width: 4.4rem;
  font-size: 0.82rem;
}

.chat-message {
  border: 1px solid rgba(83, 58, 32, 0.1);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.6);
}

.chat-message.user {
  background: rgba(158, 47, 18, 0.08);
}

.chat-message.assistant {
  background: rgba(29, 106, 71, 0.09);
}

.chat-message-content {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
}

.saved-prompt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.saved-prompt-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: end;
}

.saved-prompt-toolbar .ghost-button {
  white-space: nowrap;
}

.chat-output-options {
  margin: 0;
  padding: 0.85rem 1rem 0.95rem;
  border: 1px solid rgba(83, 58, 32, 0.12);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.42);
  min-width: 0;
}

.chat-output-options legend {
  padding: 0 0.35rem;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.checkbox-field + .checkbox-field {
  margin-top: 0.55rem;
}

.checkbox-field input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.vision-preview-frame {
  display: grid;
  place-items: center;
  min-height: 22rem;
  margin-top: 1rem;
  border: 1px solid rgba(83, 58, 32, 0.1);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
}

.vision-preview {
  display: block;
  max-width: 100%;
  max-height: 34rem;
  object-fit: contain;
}

.hidden {
  display: none;
}

.prompt-editor-dialog {
  width: min(52rem, calc(100vw - 2rem));
  border: 1px solid var(--panel-border);
  border-radius: 1.5rem;
  padding: 0;
  background: rgba(255, 250, 241, 0.98);
  box-shadow: var(--shadow);
}

.prompt-editor-dialog::backdrop {
  background: rgba(24, 17, 10, 0.42);
  backdrop-filter: blur(4px);
}

.prompt-editor-form {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.legal-panel {
  display: grid;
  gap: 1rem;
}

.legal-panel p,
.legal-panel li {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  line-height: 1.55;
}

.legal-panel ul {
  margin: 0;
  padding-left: 1.2rem;
}

.legal-panel h3 {
  margin: 0.4rem 0 0;
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 1rem 0 0.25rem;
  border-top: 1px solid rgba(83, 58, 32, 0.12);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--muted);
}

.site-footer nav {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.privacy-banner {
  position: sticky;
  bottom: 1rem;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(83, 58, 32, 0.14);
  border-radius: 1.2rem;
  background: rgba(255, 250, 241, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.privacy-banner-copy {
  display: grid;
  gap: 0.35rem;
}

.privacy-banner-copy p {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.privacy-banner-copy strong {
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.privacy-banner-actions {
  display: flex;
  align-items: start;
}

.privacy-banner.hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .grid,
  .vision-grid,
  .chat-grid {
    grid-template-columns: 1fr;
  }

  .saved-prompt-grid {
    grid-template-columns: 1fr;
  }

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

  .privacy-banner {
    grid-template-columns: 1fr;
  }

  .chat-composer-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-self: auto;
    position: static;
  }

  .chat-form-row-compact,
  .chat-attachments-body {
    grid-template-columns: 1fr;
  }

  .hero-actions,
  .panel-heading,
  .card-actions {
    flex-wrap: wrap;
  }

  .hero-topline {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-topline-actions {
    justify-content: flex-start;
  }

  .chat-vision-link {
    margin-right: 0;
  }

  .chat-config-panel {
    position: static;
  }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

  .hero-actions,
  .panel-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-history {
    max-height: none;
  }

  .profile-meta dd {
    text-align: left;
  }
}
