*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary:       #db0000;
  --color-primary-dark:  #a80000;
  --color-primary-light: #ff2020;
  --color-secondary:     #6b7280;
  --color-success:       #16a34a;
  --color-danger:        #dc2626;
  --color-warning-bg:    #fffbeb;
  --color-warning-border:#fcd34d;
  --color-warning-text:  #92400e;
  --color-bg:            #F5F4F0;
  --color-surface:       #ffffff;
  --color-border:        #E2DFD8;
  --color-text:          #1A1A1A;
  --color-text-muted:    #6b6b6b;
  --color-header-bg:     #111111;
  --radius:              8px;
  --shadow:              0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:           0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  line-height: 1.5;
}

.app-header {
  background: var(--color-header-bg);
  color: white;
  padding: 16px 32px;
  box-shadow: var(--shadow);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  height: 44px;
  width: auto;
}

.header-rat {
  height: 32px;
  width: auto;
  filter: invert(1);
  opacity: 0.6;
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.header-subtitle {
  font-size: 12px;
  opacity: .65;
  margin-top: 2px;
}

.tab-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 32px;
  display: flex;
  gap: 4px;
}

.tab-btn {
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  font-family: inherit;
}

.tab-btn:hover { color: var(--color-primary); }

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.app-main {
  max-width: 860px;
  margin: 32px auto;
  padding: 0 24px 48px;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hidden { display: none; }

.tab-panel.hidden { display: none; }

.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 20px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header-row .section-title { margin-bottom: 0; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group + .form-group { margin-top: 20px; }

label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
}

input[type="file"] {
  padding: 8px 10px;
  cursor: pointer;
}

.drop-zone {
  position: relative;
  border: 2px dashed var(--color-border);
  border-radius: 6px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--color-bg);
  transition: border-color .15s, background .15s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-primary);
  background: rgba(30,77,140,.04);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  padding: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.drop-zone-icon {
  font-size: 22px;
  color: var(--color-text-muted);
  line-height: 1;
}

.drop-zone-text {
  font-size: 14px;
  color: var(--color-text-muted);
}

.drop-zone-link {
  color: var(--color-primary);
  text-decoration: underline;
}

.drop-zone-hint {
  font-size: 12px;
  color: var(--color-text-muted);
}

.drop-zone-filename {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-top: 6px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,58,107,.18);
}

textarea {
  resize: vertical;
  min-height: 100px;
}


.input-with-action {
  display: flex;
  gap: 8px;
}

.input-with-action input { flex: 1; }


.summary-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.summary-label-row label { margin-bottom: 0; }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
  color: var(--color-primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover { color: var(--color-primary-dark); }

.cycling-word {
  display: inline-block;
  color: #db0000;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.field-error {
  font-size: 12px;
  color: var(--color-danger);
}

.field-error.hidden { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  line-height: 1;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}

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

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover { background: var(--color-border); }

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover { opacity: .85; }

.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-lg { padding: 13px 28px; font-size: 15px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--color-text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: inherit;
}

.btn-icon:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.api-key-actions { display: flex; gap: 8px; margin-top: 10px; }

.warning-banner {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-warning-text);
}

.warning-banner strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.warning-banner p { margin-bottom: 8px; }

.warning-banner ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-message {
  font-size: 13px;
  min-height: 18px;
}

.status-message.success { color: var(--color-success); }
.status-message.error   { color: var(--color-danger); }
.status-message.loading { color: var(--color-text-muted); font-style: italic; }

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  color: var(--color-text-muted);
  font-size: 14px;
  text-align: center;
  padding: 32px 0;
}

.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
}

.profile-card-name {
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-default-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-success);
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 4px;
  padding: 1px 7px;
  letter-spacing: .01em;
}

.profile-card-actions {
  display: flex;
  gap: 8px;
}

.generate-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

#loading-indicator,
#verify-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 20px 0 8px;
}

#loading-indicator.hidden,
#verify-loading.hidden { display: none; }

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--color-border);
  border-top-color: #db0000;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 14px;
}

#verify-loading.success .loading-spinner {
  border-color: #16a34a;
  border-top-color: #16a34a;
  animation: success-pop .5s cubic-bezier(.175, .885, .32, 1.275) forwards;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #16a34a;
}

#verify-loading.success .loading-spinner::after {
  content: '✓';
}

#verify-loading.success .loading-text {
  color: #16a34a;
  font-weight: 500;
}

@keyframes success-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.loading-text {
  font-size: 14px;
  color: var(--color-text-muted);
}

.loading-dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

.mode-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 22px;
  transition: background .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.toggle-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.step-log {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  font-size: 15px;
}

.step-log.hidden { display: none; }

.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;
}

.verify-anim {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 20px 0 8px;
  gap: 16px;
}
.verify-anim.hidden { display: none; }

.verify-anim-fade-out { animation: verify-anim-fade-out .25s ease-in forwards; }
@keyframes verify-anim-fade-out { to { opacity: 0; } }

.verify-anim-dots { display: flex; gap: 10px; }
.verify-anim-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background .2s, transform .2s;
}
.verify-anim-dot.active { background: var(--color-primary); transform: scale(1.3); }
.verify-anim-dot.done   { background: var(--color-success); }

.verify-anim-viewport {
  position: relative;
  width: 100%;
  min-height: 180px;
  overflow: hidden;
}

.verify-anim-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

@keyframes verify-anim-slide-in  { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: translateX(0); } }
@keyframes verify-anim-slide-out { to   { opacity: 0; transform: translateX(-32px); } }
.verify-anim-stage-enter { animation: verify-anim-slide-in  .3s ease-out; }
.verify-anim-stage-exit  { animation: verify-anim-slide-out .22s ease-in forwards; }

.verify-anim-icon-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.verify-anim-icon-box {
  width: 64px;
  height: 64px;
  color: var(--color-primary);
}
.verify-anim-icon-box svg { width: 100%; height: 100%; }

.verify-anim-arrow {
  width: 40px;
  height: 22px;
  color: var(--color-border);
  flex-shrink: 0;
}
.verify-anim-arrow svg { width: 100%; height: 100%; }

.verify-anim-scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--color-primary);
  pointer-events: none;
}

.verify-anim-pulse {
  border-radius: 50%;
  animation: step-flow-pulse 1.6s ease-in-out infinite;
}

.verify-anim-typing {
  display: flex;
  gap: 6px;
  margin-top: -6px;
}
.verify-anim-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
}

.verify-anim-caption { font-size: 14px; color: var(--color-text-muted); }

.verify-anim-batch { font-size: 12px; color: var(--color-text-muted); opacity: .75; }
.verify-anim-batch.hidden { display: none; }

.verify-anim-count { font-size: 32px; font-weight: 700; color: var(--color-primary); }
.verify-anim-count.hidden { display: none; }
.verify-anim-count-pop { animation: success-pop .4s cubic-bezier(.175, .885, .32, 1.275) both; }

.step-item {
  color: var(--color-text-muted);
  padding: 12px 4px;
  border-radius: 6px;
  transition: background .15s;
}

.step-item + .step-item { border-top: 1px solid var(--color-border); }

.step-item.running { color: var(--color-primary); background: rgba(219,0,0,.05); }
.step-item.done    { color: var(--color-success); }
.step-item.error   { color: var(--color-danger); }

.step-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.step-cat-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-cat-icon svg { width: 100%; height: 100%; }

.step-icon {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  font-size: 14px;
}

.step-icon.spinning {
  display: inline-block;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.step-text {
  font-weight: 600;
  color: var(--color-text);
}

.step-item.running .step-text { color: var(--color-primary); }
.step-item.done    .step-text { color: var(--color-success); }
.step-item.error   .step-text { color: var(--color-danger); }

.step-timer {
  font-size: 12px;
  opacity: .6;
  flex-shrink: 0;
}

.step-toggle {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
  color: inherit;
  opacity: .7;
}

.step-toggle:hover { opacity: 1; }

.step-detail {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-detail.hidden { display: none; }

.step-detail-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.step-detail-pre {
  margin: 0;
  padding: 12px 14px;
  background: #1a1a1a;
  color: #d4d4d4;
  border-radius: 5px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
  max-height: 320px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 101;
  margin: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 0 0 var(--radius) var(--radius);
}

.chat-modal-content {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-modal-content .modal-body {
  flex: 1;
  display: flex;
  gap: 20px;
  padding: 24px 32px;
  overflow: hidden;
}

.chat-progress {
  font-size: 13px;
  color: var(--color-text-muted);
}

.chat-preview {
  flex: 1 1 55%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.preview-tab {
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
}

.preview-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}

.sheet-tabs.hidden { display: none; }

.sheet-tab {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 10px;
}

.sheet-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.chat-preview-body {
  flex: 1;
  overflow: auto;
  padding: 24px 28px;
  font-size: 14px;
  line-height: 1.7;
}

.chat-preview-body p { margin: 0 0 12px; }

.chat-preview-body table {
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.chat-preview-body table td,
.chat-preview-body table th {
  border: 1px solid var(--color-border);
  padding: 4px 8px;
}

.doc-preview-empty,
.doc-preview-loading {
  color: var(--color-text-muted);
  font-style: italic;
}

mark.doc-highlight {
  background: transparent;
  border-bottom: 2px solid transparent;
  border-radius: 2px;
  padding: 0 1px;
  transition: background .2s, border-color .2s;
}

mark.doc-highlight.yellow { border-color: var(--color-warning-border); }
mark.doc-highlight.red    { border-color: #fca5a5; }

td.doc-highlight.yellow { background: rgba(252, 211, 77, .3); }
td.doc-highlight.red    { background: rgba(252, 165, 165, .4); }
td.doc-highlight.active.yellow { background: var(--color-warning-border); font-weight: 700; }
td.doc-highlight.active.red    { background: #fca5a5; font-weight: 700; }

mark.doc-highlight.active.yellow { background: var(--color-warning-border); }
mark.doc-highlight.active.red    { background: #fca5a5; }

.chat-modal-content .chat-thread {
  flex: 1 1 45%;
  min-width: 0;
  max-height: none;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
}

@media (max-width: 860px) {
  .chat-modal-content .modal-body { flex-direction: column; }
  .chat-preview, .chat-modal-content .chat-thread { flex: none; max-height: 38vh; }
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

@keyframes chat-msg-enter {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg-enter {
  animation: chat-msg-enter .22s ease-out;
}

@keyframes chat-thread-slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

.chat-thread-enter {
  animation: chat-thread-slide-in .3s ease-out;
}

@keyframes chat-thread-slide-out {
  to { opacity: 0; transform: translateX(-24px); }
}

.chat-thread-exit {
  animation: chat-thread-slide-out .2s ease-in forwards;
}

.chat-msg-badge {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.chat-badge-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-success);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  animation: chat-badge-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes chat-badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

.chat-badge-text {
  animation: chat-msg-enter .3s ease-out .15s both;
}

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

.chat-input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-row textarea {
  min-height: 72px;
  resize: vertical;
}

.chat-input-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.chat-ack-row {
  display: flex;
  justify-content: flex-end;
}

.chat-input-row.hidden,
.chat-ack-row.hidden {
  display: none;
}

.verify-intro {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.verify-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.verify-summary-chip {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: opacity .15s;
}

.verify-summary-chip.match    { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.verify-summary-chip.mismatch { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.verify-summary-chip.notfound { background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.verify-summary-chip.inactive { opacity: .35; }

.verify-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.verify-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.verify-table thead tr {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.verify-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}

.verify-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.verify-table tbody tr:last-child td { border-bottom: none; }

.verify-row-match    { background: #f0fdf4; }
.verify-row-mismatch { background: #fff5f5; }
.verify-row-notfound { background: var(--color-surface); }

.verify-cell-label { max-width: 300px; word-wrap: break-word; }
.verify-cell-value { font-variant-numeric: tabular-nums; white-space: nowrap; }

.verify-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.verify-badge.match           { background: #dcfce7; color: #15803d; }
.verify-badge.mismatch        { background: #fee2e2; color: #b91c1c; }
.verify-badge.notfound        { background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.verify-badge.cause-root      { background: #fef3c7; color: #92400e; }
.verify-badge.cause-cascading { background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }

.verify-row-indented .verify-cell-label { padding-left: 28px; }

.verify-download-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.summary-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid;
}

.summary-card.not-found { background: var(--color-warning-bg);  border-color: var(--color-warning-border); }
.summary-card.mismatch  { background: #fff5f5;                  border-color: #fca5a5; }
.summary-card.clean     { background: #f0fdf4;                  border-color: #86efac; }

.summary-card-header {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.summary-card.not-found .summary-card-header { color: var(--color-warning-text); }
.summary-card.mismatch  .summary-card-header { color: #b91c1c; }
.summary-card.clean     .summary-card-header { color: var(--color-success); }

.summary-card-explanation {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: 10px;
}

.summary-card-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.summary-card-item      { font-size: 13px; color: var(--color-text-muted); }
.summary-card-item-diff { font-variant-numeric: tabular-nums; }

.summary-card-items.hidden { display: none; }

.summary-card .summary-collapsed-toggle { display: block; margin-bottom: 8px; }

.summary-collapsed {
  margin-top: 14px;
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}

.summary-collapsed-toggle {
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
}

.summary-collapsed-body { margin-top: 10px; }
.summary-collapsed-body.hidden { display: none; }

.summary-collapsed-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.summary-collapsed-item:last-child { border-bottom: none; }

.summary-collapsed-item-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.summary-collapsed-item-explanation {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.step-rerun-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 4px;
  margin-left: 6px;
  text-decoration: none;
  transition: color .15s;
}
.step-rerun-btn:hover { color: var(--color-primary); }


.how-it-works-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  font-size: 20px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: background .15s, transform .15s;
}

.how-it-works-btn:hover {
  background: var(--color-primary-dark);
  transform: scale(1.06);
}

.how-it-works-content {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.how-it-works-content .modal-header {
  padding: 24px 48px;
}

.how-it-works-content .modal-header h3 {
  font-size: 24px;
}

.how-it-works-content .btn-icon {
  font-size: 30px;
}

.how-it-works-content .modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 48px 48px;
}

.how-it-works-intro {
  font-size: 17px;
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 820px;
  margin: 0 auto 24px;
  padding-bottom: 24px;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}

#how-it-works-flow {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.step-flow-stage {
  flex: 1;
  min-height: 50vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  cursor: pointer;
  padding: 16px 8px;
}

.step-flow-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
}

.step-flow-caption {
  font-size: 19px;
  color: var(--color-text-muted);
  line-height: 1.7;
  max-width: 680px;
  margin: 0 auto;
}

.step-flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}

.step-flow-icon-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.step-flow-icon-box svg {
  width: 88px;
  height: 88px;
  color: var(--color-primary);
}

.step-flow-icon-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: center;
  max-width: 150px;
}

.step-flow-arrow {
  width: 52px;
  height: 30px;
  color: var(--color-border);
  flex-shrink: 0;
}

.step-flow-arrow svg { width: 100%; height: 100%; }

.step-flow-chip {
  display: inline-block;
  padding: 8px 22px;
  border-radius: 24px;
  font-size: 18px;
  font-weight: 600;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.step-flow-chip.highlight {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
  animation: step-flow-pop .4s ease both, step-flow-pulse 1.6s ease-in-out infinite;
}

.step-flow-chip.mismatch {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.step-flow-snippet {
  margin: 0;
  padding: 22px 26px;
  background: #1a1a1a;
  color: #d4d4d4;
  border-radius: 8px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 17px;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
  align-self: center;
  max-width: 100%;
}

.step-flow-doc-line {
  font-size: 19px;
  color: var(--color-text-muted);
  text-align: center;
}

.step-flow-stage .chat-thread {
  max-height: none;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  gap: 16px;
}

.step-flow-stage .chat-msg {
  font-size: 18px;
  padding: 14px 20px;
  max-width: 85%;
}

.step-flow-stage .summary-card {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 26px;
}

.step-flow-stage .summary-card-header {
  font-size: 18px;
}

.step-flow-stage .summary-card-explanation {
  font-size: 16px;
  margin-bottom: 0;
}

.step-flow-anim {
  animation: step-flow-pop .4s ease both;
}

@keyframes step-flow-pop {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes step-flow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(252,211,77,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(252,211,77,0); }
}

.step-flow-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 28px 0;
}

.step-flow-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background .2s, transform .2s;
}

.step-flow-dot.active {
  background: var(--color-primary);
  transform: scale(1.3);
}

.step-flow-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.step-flow-controls .btn {
  padding: 14px 32px;
  font-size: 17px;
}

.step-flow-restart {
  font-size: 16px;
}

.step-flow-restart.hidden { display: none; }

.step-flow-try-it-btn {
  align-self: center;
  padding: 16px 40px;
  font-size: 18px;
}

.tutorial-download-modal .modal-content { max-width: 520px; }

.tutorial-sample-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.tutorial-sample-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
}

.tutorial-sample-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

.tutorial-sample-icon svg { width: 100%; height: 100%; }

.tutorial-sample-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.tutorial-downloaded, .tutorial-downloaded:hover {
  background: transparent;
  color: var(--color-success);
  border-color: var(--color-success);
}

.tutorial-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.tutorial-guide-card {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 110;
  max-width: 340px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px 36px 16px 16px;
}

.tutorial-guide-card p {
  font-size: 14px;
  line-height: 1.5;
}

.tutorial-guide-card .tutorial-exit-btn {
  position: absolute;
  top: 6px;
  right: 6px;
}

.tutorial-pointer {
  position: fixed;
  z-index: 111;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: tutorial-bounce 1.4s ease-in-out infinite;
}

.tutorial-pointer-below { flex-direction: column-reverse; }

.tutorial-pointer-bubble {
  background: var(--color-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  max-width: 240px;
  text-align: center;
}

.tutorial-pointer-arrow {
  width: 16px;
  height: 10px;
}

.tutorial-pointer-arrow::before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--color-primary);
}

.tutorial-pointer-below .tutorial-pointer-arrow::before {
  border-top: none;
  border-bottom: 10px solid var(--color-primary);
}

@keyframes tutorial-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.app-footer {
  text-align: center;
  padding: 16px 32px 24px;
  font-size: 12px;
  color: var(--color-text-muted);
}

@media (max-width: 600px) {
  .app-header { padding: 16px 20px; }
  .tab-nav { padding: 0 16px; }
  .app-main { margin: 20px auto; padding: 0 16px 32px; }
  .section-card { padding: 20px 16px; }

  .how-it-works-content .modal-header { padding: 18px 20px; }
  .how-it-works-content .modal-header h3 { font-size: 19px; }
  .how-it-works-content .modal-body { padding: 20px 20px 32px; }
  .how-it-works-intro { font-size: 15px; }
  .step-flow-title { font-size: 24px; }
  .step-flow-caption { font-size: 16px; }
  .step-flow-icon-box svg { width: 56px; height: 56px; }
  .step-flow-arrow { width: 36px; height: 20px; }
  .step-flow-snippet { font-size: 14px; padding: 16px 18px; }
  .step-flow-chip { font-size: 15px; padding: 6px 16px; }
  .step-flow-controls .btn { padding: 12px 22px; font-size: 15px; }
  .tutorial-guide-card { left: 16px; right: 16px; max-width: none; }
}
