:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #141414;
  --muted: #667085;
  --line: #d8dde5;
  --accent: #126dff;
  --accent-ink: #ffffff;
  --soft: #f6f8fb;
  --danger: #c1272d;
  --shadow: 0 18px 50px rgba(22, 34, 51, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 22px;
  min-height: calc(100vh - 48px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand-row p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
  font-size: 14px;
}

.icon-button,
.message-tool {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.icon-button:hover,
.message-tool:hover,
.secondary-button:hover,
.compact-button:hover,
.tab-button:hover,
.scale-button:hover {
  background: var(--soft);
}

.icon-button svg,
.compact-button svg,
.primary-button svg,
.secondary-button svg,
.message-tool svg,
.drop-zone svg {
  width: 18px;
  height: 18px;
}

.section-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.tab-button,
.scale-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.tab-button.active,
.scale-button.active {
  background: #111827;
  color: #fff;
}

.tab-panel {
  display: none;
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 16px;
  line-height: 1.2;
}

.compact-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
  font-weight: 750;
  white-space: nowrap;
}

.compact-button,
.secondary-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.primary-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-ink);
}

.primary-button:hover {
  background: #075bd8;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.message-editor-header {
  display: grid;
  grid-template-columns: 1fr 46px 38px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}

.message-editor textarea,
.field textarea,
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.message-editor textarea:focus,
.field textarea:focus,
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 109, 255, 0.14);
}

.message-editor-header input[type="text"] {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-weight: 700;
}

.message-editor-header input[type="color"] {
  width: 46px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.message-editor textarea {
  display: block;
  min-height: 82px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  padding: 12px;
  line-height: 1.4;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  text-align: center;
  border: 1px dashed #9aa6b2;
  border-radius: 8px;
  background: var(--soft);
  color: #344054;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #eef6ff;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone strong {
  font-size: 15px;
}

.drop-zone span,
.ocr-status {
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.45;
}

.field input,
.field select {
  height: 40px;
  padding: 0 10px;
}

.field input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.import-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.ocr-status {
  min-height: 18px;
  margin-top: 12px;
}

.style-grid,
.speaker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.speaker-grid {
  margin-top: 12px;
}

.preview-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  gap: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, 64px);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.preview-stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px;
  background:
    linear-gradient(45deg, #dfe4ea 25%, transparent 25%),
    linear-gradient(-45deg, #dfe4ea 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe4ea 75%),
    linear-gradient(-45deg, transparent 75%, #dfe4ea 75%);
  background-color: #f8fafc;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.shot-canvas {
  width: 1440px;
  min-height: 900px;
  padding: 78px;
  background: #fff;
  color: #000;
  font-family: Helvetica, Arial, sans-serif;
  transform-origin: top left;
  box-shadow: 0 12px 38px rgba(15, 23, 42, 0.16);
}

.shot-message {
  margin: 0 0 var(--message-gap, 104px);
}

.shot-message:last-child {
  margin-bottom: 0;
}

.shot-name {
  margin: 0 0 24px;
  font-size: var(--shot-font-size, 66px);
  line-height: 1.05;
  font-weight: var(--name-weight, 800);
  letter-spacing: 0;
}

.shot-text {
  margin: 0;
  max-width: 100%;
  font-size: var(--shot-font-size, 66px);
  line-height: var(--shot-line-height, 1.25);
  font-weight: 400;
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 700;
  transform: translateY(20px);
  opacity: 0;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  z-index: 10;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    padding: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .controls-panel {
    max-height: none;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented,
  .toolbar-actions {
    width: 100%;
  }

  .segmented {
    grid-template-columns: repeat(4, 1fr);
  }

  .toolbar-actions .primary-button,
  .toolbar-actions .secondary-button {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .style-grid,
  .speaker-grid {
    grid-template-columns: 1fr;
  }

  .message-editor-header {
    grid-template-columns: 1fr 46px 38px;
  }

  .brand-row {
    padding: 18px;
  }

  .tab-panel {
    padding: 14px;
  }

  .preview-stage {
    padding: 12px;
  }
}
