:root {
  color-scheme: light;
  --app-bg: #f3f4f6;
  --panel-bg: #ffffff;
  --editor-bg: #fff3dc;
  --text: #1f2937;
  --muted: #667085;
  --border: #d1d5db;
  --border-strong: #9ca3af;
  --primary: #4b5563;
  --primary-hover: #374151;
  --danger-bg: #f8d7da;
  --danger-border: #c2414b;
  --focus: #6b7280;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--app-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.app-shell {
  width: min(1180px, calc(100vw - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 0 20px;
}

.product-panel,
.editor-panel,
.chat-panel {
  border: 1px solid var(--border);
  background: var(--panel-bg);
}

.product-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  padding: 14px;
}

.product-row {
  min-width: 0;
}

.product-id-row,
.product-name-row {
  grid-column: 1 / 2;
}

.product-description-row {
  grid-column: 1 / -1;
}

.item-id-value {
  min-height: 20px;
  color: var(--muted);
  font-weight: 700;
}

.top-actions {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  display: flex;
  align-items: end;
  gap: 8px;
}

.session-line {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
  gap: 14px;
  margin-top: 14px;
}

.editor-panel,
.chat-panel {
  min-height: 560px;
  padding: 16px;
}

.editor-panel {
  background: var(--editor-bg);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto auto;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

.field-label {
  display: block;
  margin: 0 0 4px;
  font-weight: 700;
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  outline: none;
}

.text-input {
  height: 38px;
  padding: 6px 8px;
}

.text-area {
  min-height: 74px;
  padding: 8px;
  resize: vertical;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.16);
}

.text-input[readonly],
.text-area[readonly] {
  color: #374151;
  background: #f9fafb;
}

.tagline-grid {
  display: grid;
  gap: 7px;
}

.tagline-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.tagline-label {
  font-weight: 700;
}

.tagline-input.ai-edited {
  background: #fff0a6;
}

.history {
  overflow: auto;
  min-height: 280px;
  max-height: 52vh;
  padding: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  white-space: pre-wrap;
}

.history-line {
  margin: 0 0 8px;
}

.history-speaker {
  font-weight: 700;
}

.status {
  min-height: 24px;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 700;
}

.chat-input-row {
  margin-top: 8px;
}

.chat-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.elapsed-timer {
  min-height: 18px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

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

.button {
  min-width: 86px;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #e5e7eb;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  background: #d1d5db;
}

.button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

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

.button.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: #7f1d1d;
}

.button.subtle {
  background: #f9fafb;
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.58;
}

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

  .top-actions {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-content: flex-end;
  }

  .editor-panel,
  .chat-panel {
    min-height: auto;
  }

  .history {
    max-height: 360px;
  }
}
