/*
 * Solid field ticket — triplicate work-order look.
 * White sheet = you. Canary carbon = the gateway. Pink file copy = confirm.
 * Copper = action (pipe, not terracotta). Gas-service blue = the stub.
 */

:root {
  --paper: #f7f4ec;
  --paper-deep: #efeadd;
  --ink: #1e2a33;
  --muted: #3d4a54;
  --stub: #12304a;
  --stub-ink: #edf3f8;
  --copper: #9c4a1a;
  --copper-press: #7c3a12;
  --canary: #fff8e6;
  --file-pink: #f8e5de;
  --stamp: #8c1f14;
  --rule: #8b96a0;
  --rule-soft: #c9cec9;
  --focus: #0b5fbf;
  --backdrop: #39434c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--backdrop);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
}

body {
  padding: 12px;
}

/* ---------- skip link ---------- */

.skip {
  position: absolute;
  left: 12px;
  top: 0;
  z-index: 2;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  border-radius: 0 0 6px 6px;
  transform: translateY(-120%);
}

.skip:focus {
  transform: translateY(0);
}

/* ---------- the ticket ---------- */

.ticket {
  max-width: 30rem;
  margin: 0 auto;
  background: var(--paper);
  border-radius: 10px;
  min-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 1px 2px rgba(10, 16, 22, 0.35),
    0 12px 32px rgba(10, 16, 22, 0.45);
  overflow: hidden;
}

.stub {
  background: var(--stub);
  color: var(--stub-ink);
  padding: 18px 20px 20px;
  position: relative;
}

/* Signature: a punched perforation strip where the stub tears off. */
.stub::after {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: -7px;
  height: 14px;
  background-image: radial-gradient(
    circle at 7px 7px,
    var(--stub) 4.5px,
    transparent 5px
  );
  background-size: 22px 14px;
  background-repeat: repeat-x;
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #9fb6c8;
}

h1 {
  margin: 2px 0 12px;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h3 {
  margin: 0;
  font-size: 1.1rem;
}

.who,
.job-stub,
.job-source {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  color: #c3d2dd;
}

.who {
  color: var(--stub-ink);
}

.job-stub,
.job-source {
  margin-top: 4px;
}

.banner {
  margin: 12px 0 0;
  padding: 8px 12px;
  background: var(--canary);
  color: var(--ink);
  font-weight: 700;
  border-radius: 6px;
}

/* ---------- panels ---------- */

#main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel {
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.panel[hidden] {
  display: none;
}

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

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

button {
  min-height: 44px;
  min-width: 44px;
  background: var(--copper);
  color: #fff8f2;
  border: none;
  border-radius: 6px;
  padding: 12px 20px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--copper-press);
}

button:hover:not(:disabled) {
  background: var(--copper-press);
}

button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: none;
}

button.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  box-shadow: 0 2px 0 rgba(30, 42, 51, 0.35);
}

button.secondary:hover:not(:disabled) {
  background: var(--paper-deep);
}

button.text {
  background: transparent;
  color: var(--muted);
  border: none;
  box-shadow: none;
  padding: 8px 0;
  align-self: flex-start;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.text:hover:not(:disabled) {
  background: transparent;
  color: var(--ink);
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(247, 244, 236, 0.9);
}

/* Headings receive programmatic focus for screen-reader context only;
 * a ring there reads as a broken control. */
h1:focus,
h2:focus,
h3:focus {
  outline: none;
  box-shadow: none;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 700;
}

input,
textarea,
select {
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: #fffdf8;
  padding: 10px 12px;
  color: var(--ink);
  min-height: 44px;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--ink);
}

.secret,
.hint {
  font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  word-break: break-word;
  color: var(--muted);
}

.hint,
.error {
  margin: 0;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

textarea[aria-invalid="true"] {
  border-color: var(--stamp);
  outline: 2px solid var(--stamp);
  outline-offset: 1px;
}

.error {
  color: var(--stamp);
  font-weight: 700;
}

/* ---------- conversation ---------- */

.log {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 8px;
  margin: 0;
  list-style: none;
}

.bubble {
  padding: 8px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 8px;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.bubble.user {
  background: #fffdf8;
  border: 1px solid var(--rule-soft);
  align-self: flex-end;
  max-width: 88%;
  border-bottom-right-radius: 2px;
  font-weight: 600;
  font-size: 0.95rem;
}

.bubble.assistant {
  background: var(--canary);
  border: 1px solid #e6d7a8;
  border-left: 4px solid var(--copper);
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 2px rgba(30, 42, 51, 0.08);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.88rem;
  letter-spacing: 0;
  padding: 0;
}

.bubble.confirm {
  background: var(--file-pink);
  border-left-color: var(--stamp);
}

.answer-summary {
  cursor: pointer;
  font-weight: 700;
  padding: 8px 12px;
  list-style: none;
}

.answer-summary::-webkit-details-marker {
  display: none;
}

.answer-summary::before {
  content: "▾ ";
}

.answer:not([open]) > .answer-summary::before {
  content: "▸ ";
}

.bubble-body {
  padding: 0 12px 10px;
}

.bubble-body p {
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.bubble-body p:last-child {
  margin-bottom: 0;
}

.row-action {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  text-align: left;
  white-space: pre-wrap;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--rule);
  box-shadow: none;
}

.row-action.is-selected,
.row-action.is-selected:disabled {
  opacity: 1;
  cursor: default;
  background: #fff3dd;
  border-color: var(--copper);
}

.row-action.is-selected::after {
  content: "  ✓ Open";
  font-weight: 400;
  color: var(--copper);
}

.row-action:hover:not(:disabled) {
  color: var(--ink);
  background: #fff3dd;
  border-color: var(--copper);
}

.row-action:disabled {
  color: var(--ink);
  background: #fffdf8;
  opacity: 0.7;
}

.row-action.is-pending::after {
  content: "  Opening…";
  font-weight: 400;
  color: var(--muted);
}

.answer-summary:focus-visible {
  outline-offset: -3px;
}

.confirm-bar {
  border: 2px solid var(--stamp);
  border-radius: 8px;
  background: var(--file-pink);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm-bar h3 {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--stamp);
}

.confirm-bar[hidden] {
  display: none;
}

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

#confirm-write {
  background: var(--stamp);
  box-shadow: 0 2px 0 #5e130b;
}

#confirm-write:hover:not(:disabled) {
  background: #6f180f;
}

/* ---------- quick chips ---------- */

.prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.prompts legend {
  padding: 0;
  width: 100%;
  margin-bottom: 2px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.chip {
  min-height: 44px;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 8px 16px;
  box-shadow: none;
}

.chip:hover:not(:disabled) {
  background: var(--canary);
  border-color: var(--ink);
}

/* ---------- composer ---------- */

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px dashed var(--rule);
  padding-top: 14px;
}

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

#send {
  flex: 1;
}

#ptt {
  touch-action: none;
}

#ptt[aria-pressed="true"] {
  background: var(--stamp);
  color: #fffdfb;
  border-color: var(--stamp);
}

/* ---------- collapsed tools ---------- */

.tools {
  border: 1.5px solid var(--rule-soft);
  border-radius: 8px;
  background: var(--paper-deep);
}

.tools summary {
  cursor: pointer;
  min-height: 44px;
  padding: 10px 14px;
  font-weight: 700;
  list-style-position: inside;
}

.tools summary:hover {
  color: var(--copper-press);
}

.tools[open] summary {
  border-bottom: 1px dashed var(--rule-soft);
}

.upload {
  margin: 0;
}

.upload fieldset {
  margin: 0;
  padding: 14px;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload legend {
  padding: 14px 14px 0;
  font-weight: 700;
}

.check {
  flex-direction: row;
  align-items: center;
  min-height: 44px;
  font-weight: 400;
}

.check input {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  accent-color: var(--copper);
}

/* ---------- utilities ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 420px) {
  body {
    padding: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  button:active:not(:disabled) {
    transform: none;
  }
}
