:root {
  color-scheme: light;
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-strong: #ecf7f5;
  --text: #15221f;
  --muted: #5f6f6a;
  --border: #d9e4e0;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d9f2ee;
  --coral: #c2412d;
  --shadow: 0 14px 40px rgba(21, 34, 31, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34rem),
    linear-gradient(315deg, rgba(194, 65, 45, 0.08), transparent 28rem),
    var(--bg);
}

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

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  padding: 1rem clamp(1rem, 4vw, 3rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 750;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font-weight: 850;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 0.65fr);
  grid-template-areas:
    "capture side"
    "history side";
  gap: clamp(1rem, 2.5vw, 2rem);
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto 3rem;
  align-items: start;
}

.capture-panel {
  grid-area: capture;
  display: grid;
  gap: 1.2rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.prompt-block h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(2rem, 4.6vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.prompt-block p {
  max-width: 620px;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.capture-form,
.profile-form,
.sms-form,
.side-stack {
  display: grid;
  gap: 1rem;
}

.side-stack {
  grid-area: side;
}

.surface,
.history-panel {
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
}

.history-panel {
  grid-area: history;
  min-height: 220px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.trigger-surface {
  padding: clamp(1.25rem, 3vw, 1.55rem);
  background: #fff;
  box-shadow: 0 10px 28px rgba(21, 34, 31, 0.06);
}

.trigger-surface .section-heading {
  margin-bottom: 0.55rem;
}

.trigger-surface .section-heading h2 {
  font-size: clamp(1.32rem, 2.8vw, 1.7rem);
  line-height: 1.1;
}

.trigger-lead {
  margin: 0 0 1.1rem;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

.sms-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sms-form h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.2;
}

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

.input-control,
.textarea-control,
.select-control {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
  outline: none;
}

.input-control,
.select-control {
  padding: 0 0.85rem;
}

.textarea-control {
  resize: vertical;
  min-height: 156px;
  padding: 0.85rem;
  line-height: 1.5;
}

.input-control:focus,
.textarea-control:focus,
.select-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.capture-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.tool-button,
.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  min-height: 44px;
  border: 1px solid var(--border);
  font-weight: 750;
  text-decoration: none;
}

.tool-button,
.secondary-button,
.icon-button {
  color: var(--text);
  background: #fff;
}

.danger-button {
  color: var(--coral);
  background: #fff;
}

.tool-button:hover,
.secondary-button:hover,
.danger-button:hover,
.icon-button:hover {
  border-color: #b9c8c4;
  background: #f8fbfa;
}

.primary-button {
  min-height: 52px;
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 0.6rem;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 0.78rem;
  font-weight: 780;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 40px;
  font-weight: 650;
}

.toggle-row input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.identity-fields {
  display: grid;
  gap: 0.75rem;
}

.notify-grid {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 0.65rem 0.75rem;
  align-items: center;
  margin-bottom: 0.9rem;
}

.compact {
  text-align: center;
}

.media-status,
.small-text {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.workshop-note {
  margin: -0.35rem 0 0;
}

.workshop-note a {
  color: var(--accent-strong);
  font-weight: 750;
}

.media-status strong {
  color: var(--coral);
}

.history-list {
  display: grid;
  gap: 0.8rem;
}

.entry-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.entry-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.attachment-chip,
.attachment-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 30px;
  padding: 0 0.55rem;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f4f2;
  font-size: 0.8rem;
  font-weight: 700;
}

.attachment-action {
  border: 1px solid var(--border);
  cursor: pointer;
}

.attachment-action:hover {
  border-color: #b9c8c4;
  background: #e7efec;
}

.photo-attachment {
  display: grid;
  gap: 0.35rem;
  width: min(180px, 100%);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
}

.photo-attachment img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f0f4f2;
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 20;
  width: min(420px, calc(100vw - 2rem));
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  color: #fff;
  background: #15221f;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 700;
}

.icon {
  width: 1.05rem;
  height: 1.05rem;
  display: inline-block;
  background: currentColor;
  flex: 0 0 auto;
}

.icon-mic {
  clip-path: path("M8 1.5a3 3 0 0 0-3 3V8a3 3 0 1 0 6 0V4.5a3 3 0 0 0-3-3Zm-4.8 6A.8.8 0 0 1 4 8.3 4 4 0 0 0 12 8.3a.8.8 0 0 1 1.6 0 5.6 5.6 0 0 1-4.8 5.54V16H7.2v-2.16A5.6 5.6 0 0 1 2.4 8.3a.8.8 0 0 1 .8-.8Z");
}

.icon-stop {
  clip-path: inset(18% round 2px);
}

.icon-camera {
  clip-path: path("M3 4h2l1-1.5h4L11 4h2a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm5 2.5A3.5 3.5 0 1 0 8 13a3.5 3.5 0 0 0 0-7Zm0 1.4A2.1 2.1 0 1 1 8 12.1 2.1 2.1 0 0 1 8 7.9Z");
}

.icon-send {
  clip-path: polygon(5% 8%, 95% 50%, 5% 92%, 20% 56%, 58% 50%, 20% 44%);
}

.icon-refresh {
  clip-path: path("M12.8 4.6A5.6 5.6 0 0 0 3.1 7H1.4A7.2 7.2 0 0 1 13.8 3.5V1.3H15v4.8h-4.8V4.9h2.3l.3-.3ZM3.2 11.4A5.6 5.6 0 0 0 12.9 9h1.7A7.2 7.2 0 0 1 2.2 12.5v2.2H1V9.9h4.8v1.2H3.5l-.3.3Z");
}

@media (max-width: 820px) {
  .topbar {
    min-height: 64px;
    padding-inline: 1rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "capture"
      "side"
      "history";
  }

  .capture-tools {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: toast-in 160ms ease-out;
  }

  @keyframes toast-in {
    from {
      transform: translate(-50%, 8px);
      opacity: 0;
    }
    to {
      transform: translate(-50%, 0);
      opacity: 1;
    }
  }
}
