/* ── Reset & Base ─────────────────────────────────────────────────────────── */
/* Токены дизайна — в static/tokens.css (подключается перед этим файлом). */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--label);
  min-height: 100vh;
}

/* ── Auth Layout ──────────────────────────────────────────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--elev-2);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon { display: flex; justify-content: center; margin-bottom: 10px; color: var(--accent); }

.logo-text {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--label);
}
.logo-text span { color: var(--accent); }

.logo-sub {
  font-size: 14px;
  color: var(--label4);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

.auth-card h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}

.auth-desc {
  font-size: 15px;
  color: var(--label3);
  line-height: 1.5;
  margin-bottom: 24px;
}

/* ── Sent State ───────────────────────────────────────────────────────────── */
.sent-state { text-align: center; }
.sent-icon { display: flex; justify-content: center; margin-bottom: 16px; color: var(--accent); }
.sent-state h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.sent-state p { font-size: 15px; color: var(--label3); line-height: 1.5; margin-bottom: 8px; }
.sent-state .note { font-size: 13px; color: var(--label4); margin-bottom: 24px; }

/* ── Error Banner ─────────────────────────────────────────────────────────── */
.error-banner {
  background: #fff2f0;
  border: 1px solid #ffccc7;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: #cf1322;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.error-icon { flex-shrink: 0; display: inline-flex; }

/* ── Иконки (набор Lucide, наследуют цвет текста) ─────────────────────────── */
.ic  { width: 18px; height: 18px; display: inline-block; vertical-align: -0.18em; flex: none; }
.ic-sm { width: 14px; height: 14px; display: inline-block; vertical-align: -0.15em; flex: none; }
.ic-lg { width: 40px; height: 40px; display: block; flex: none; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.auth-form, .form-fields { display: flex; flex-direction: column; gap: 16px; }

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

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--label2);
  letter-spacing: 0.1px;
}

.optional { font-weight: 400; color: var(--label4); }

.input-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--label);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.input-group input::placeholder { color: var(--label4); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #211a06;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: -0.1px;
  box-shadow: var(--elev-1);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn-primary:hover:not(:disabled) { background: var(--c-gold-strong); box-shadow: var(--elev-2); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  padding: 10px 20px;
  background: var(--bg);
  color: var(--label);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--separator); }

.btn-logout {
  padding: 7px 14px;
  background: transparent;
  color: var(--label3);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-logout:hover { background: var(--bg); }

/* ── App Header ───────────────────────────────────────────────────────────── */
.app-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--separator);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--label);
}
.header-logo span:first-of-type { color: var(--accent); }
.header-product { font-weight: 400; color: var(--label3); margin-left: 6px; font-size: 15px; }

.header-right { display: flex; align-items: center; gap: 12px; }
.header-email { font-size: 13px; color: var(--label4); }
.header-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600;
  color: var(--label2); text-decoration: none; padding: 6px 10px; border-radius: var(--radius-sm);
  transition: color .15s, background .15s; }
.header-link:hover { color: var(--accent); background: var(--accent-bg); }
.header-link svg { width: 15px; height: 15px; }
@media (max-width: 600px) { .header-link span, .header-email { display: none; } }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Status Bar ───────────────────────────────────────────────────────────── */
.status-bar { display: flex; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.status-pill.busy {
  background: #fff3e0;
  color: #c05b00;
}
.status-pill.ready {
  background: #e8f5e9;
  color: #1b5e20;
}

.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.dot-green {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 28px 28px 32px;
  box-shadow: var(--elev-1);
}
.card-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}
.card-desc {
  font-size: 14px;
  color: var(--label3);
  margin-bottom: 24px;
}

/* ── Drop Zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--separator);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 20px;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.drop-zone.has-file {
  border-color: var(--green);
  background: rgba(52,199,89,0.04);
}

.drop-icon { margin-bottom: 10px; color: var(--label3); display: flex; justify-content: center; }
.drop-title { font-size: 16px; font-weight: 600; color: var(--label); margin-bottom: 4px; }
.drop-sub { font-size: 14px; color: var(--label4); }

.file-info { margin-top: 12px; }
.file-name { font-size: 15px; font-weight: 600; color: var(--label); }
.file-size { font-size: 13px; color: var(--label4); margin-top: 2px; }

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress-wrap { margin: 16px 0; }
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--label3);
  margin-bottom: 8px;
}
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--c-gold-strong), var(--accent));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.btn-upload { margin-top: 8px; }

/* ── Result Card ──────────────────────────────────────────────────────────── */
.result-card { text-align: center; padding: 36px 28px; }
.result-icon { margin-bottom: 12px; }
.ios-check {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.ios-check svg { width: 100%; height: 100%; }
@keyframes pop-in {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.result-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.result-rows { text-align: left; margin-bottom: 20px; }
.result-note { font-size: 14px; color: var(--label3); }

/* ── Status Page ──────────────────────────────────────────────────────────── */
.job-id-badge {
  display: inline-block;
  background: var(--bg);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--label3);
  margin-bottom: 24px;
  font-family: var(--font-mono);
}
.status-rows { display: flex; flex-direction: column; gap: 0; }
.srow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--separator);
  font-size: 15px;
}
.srow:last-child { border-bottom: none; }
.slabel { color: var(--label3); }
.sval { font-weight: 500; color: var(--label); text-align: right; max-width: 60%; }

.badge-green {
  background: #e8f5e9; color: #1b5e20;
  padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 600;
}
.badge-orange {
  background: #fff3e0; color: #c05b00;
  padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 600;
}
.badge-gray {
  background: var(--bg); color: var(--label3);
  padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 600;
}

/* ── Result rows ──────────────────────────────────────────────────────────── */
.rrow {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--separator);
  font-size: 15px;
}
.rrow:last-child { border-bottom: none; }
.rlabel { color: var(--label3); }
.rval { font-weight: 600; color: var(--label); }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 0; }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { color: var(--label3); font-size: 15px; }

/* ── Preset block ─────────────────────────────────────────────────────────── */
.preset-block { margin-top: 8px; }
.preset-block-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--label2);
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px;
}
.preset-sub {
  font-size: 13px; color: var(--label3); margin-bottom: 12px;
}

.help-btn {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--separator); background: var(--surface);
  color: var(--label3); font-size: 13px; font-weight: 700; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.help-btn:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

.preset-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 10px;
}
.preset-card {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; transition: all 0.15s ease;
}
.preset-card:hover { border-color: var(--accent); background: var(--accent-bg); }
.preset-card.is-active {
  border-color: var(--accent); background: var(--accent-bg);
  box-shadow: 0 0 0 3px rgba(197, 151, 42, 0.12);
}
.preset-card input[type=radio] {
  position: absolute; opacity: 0; pointer-events: none;
}
.preset-icon { color: var(--label2); display: flex; align-items: center; }
.preset-icon svg { width: 22px; height: 22px; }
.preset-card.is-active .preset-icon { color: var(--accent); }
.preset-body { flex: 1; min-width: 0; }
.preset-name {
  display: flex; align-items: flex-start; gap: 5px;
  font-size: 14px; font-weight: 600; color: var(--label); margin-bottom: 2px;
}
.preset-name-text { flex: 0 1 auto; min-width: 0; line-height: 1.3; }
.preset-short { font-size: 12px; color: var(--label3); line-height: 1.35; }
.preset-skeleton, .preset-error {
  grid-column: 1 / -1; text-align: center; color: var(--label3);
  padding: 16px; font-size: 13px;
}
.preset-error { color: var(--red); }

/* Кнопка предпросмотра состава пресета + поповер «Что внутри» */
.preset-info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; margin-top: 1px;
  width: 18px; height: 18px; padding: 0;
  border: none; background: transparent; color: var(--label3);
  border-radius: 50%; cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.preset-info-btn svg { width: 14px; height: 14px; display: block; }
.preset-info-btn:hover,
.preset-info-btn:focus-visible,
.preset-info-btn[aria-expanded="true"] {
  color: var(--accent); background: var(--accent-bg); outline: none;
}
.preset-card.is-active .preset-info-btn { color: var(--accent); }

.preset-popover {
  position: fixed; z-index: 1000; max-width: 300px; width: max-content;
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: 8px; box-shadow: var(--elev-2);
  padding: 12px 14px; font-size: 13px; color: var(--label2); line-height: 1.5;
  animation: pp-in 0.12s ease;
}
@keyframes pp-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}
.pp-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.pp-ic { display: inline-flex; color: var(--accent); }
.pp-ic svg { width: 16px; height: 16px; display: block; }
.pp-title { font-size: 14px; font-weight: 700; color: var(--label); }
.pp-hint { color: var(--label2); margin-bottom: 10px; }
.pp-label {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--label3); margin-bottom: 6px;
}
.pp-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pp-chip {
  display: inline-block; padding: 3px 9px; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--accent-bg);
  border-radius: 999px; white-space: nowrap;
}
.pp-free { color: var(--label2); }

.preset-help, .custom-prompt-help {
  margin-top: 6px; font-size: 13px; color: var(--label3);
}
.preset-help summary, .custom-prompt-help summary {
  cursor: pointer; color: var(--blue); padding: 6px 0; font-size: 13px;
  list-style: none; display: inline-block;
}
.preset-help summary::-webkit-details-marker,
.custom-prompt-help summary::-webkit-details-marker { display: none; }
.preset-help summary::before, .custom-prompt-help summary::before {
  content: "▸ "; transition: transform 0.15s ease;
}
.preset-help[open] summary::before, .custom-prompt-help[open] summary::before { content: "▾ "; }

.preset-help-body { padding: 8px 0 4px; display: flex; flex-direction: column; gap: 12px; }
.preset-help-item {
  padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm);
}
.preset-help-title { font-size: 13px; font-weight: 600; color: var(--label); margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px; }
.ph-ic { display: inline-flex; color: var(--label2); }
.preset-help-hint { font-size: 12.5px; color: var(--label2); line-height: 1.5; margin-bottom: 4px; }
.preset-help-sections {
  font-size: 12px; color: var(--label3); margin-top: 4px; font-family: monospace;
}

/* ── Custom prompt ────────────────────────────────────────────────────────── */
.custom-prompt-wrap {
  margin-top: 12px; padding: 14px; border: 1.5px dashed var(--separator);
  border-radius: var(--radius-sm); background: var(--bg);
}
.custom-prompt-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.custom-prompt-header label {
  font-size: 13px; font-weight: 600; color: var(--label2);
  text-transform: uppercase; letter-spacing: 0.4px;
}
#customPrompt {
  width: 100%; padding: 12px; border: 1px solid var(--separator);
  border-radius: var(--radius-sm); font-family: var(--font-sans);
  font-size: 14px; line-height: 1.5; resize: vertical; background: var(--surface);
  color: var(--label);
}
#customPrompt:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(197, 151, 42, 0.12); }
.custom-prompt-meta {
  font-size: 12px; color: var(--label3); text-align: right; margin-top: 4px;
}
.custom-prompt-meta.over-limit { color: var(--red); }
.custom-prompt-help-body { padding: 8px 0; font-size: 13px; color: var(--label2); }
.custom-prompt-template {
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--radius-sm); padding: 10px; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto;
  font-family: var(--font-mono); line-height: 1.5; margin: 6px 0 12px;
}
.custom-prompt-tips { padding-left: 18px; line-height: 1.6; }
.custom-prompt-tips li { margin-bottom: 4px; }

.btn-secondary {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--separator);
  background: var(--surface); color: var(--label2); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s ease;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-text {
  background: none; border: none; color: var(--label3); font-size: 12.5px;
  cursor: pointer; padding: 8px 6px; font-weight: 500;
}
.btn-text:hover { color: var(--red); }

/* ── Мои (сохранённые) промты ──────────────────────────────────────────────── */
.preset-card--user { border-style: dashed; }
.preset-card--user .preset-name { color: var(--accent); }
.preset-card--user .preset-icon { color: var(--accent); }
.pc-act svg { display: block; }
.preset-card-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 2px;
  opacity: 0; transition: opacity 0.15s ease;
}
.preset-card--user:hover .preset-card-actions,
.preset-card--user.is-active .preset-card-actions { opacity: 1; }
.pc-act {
  border: none; background: var(--surface); color: var(--label3);
  border-radius: 6px; width: 24px; height: 24px; line-height: 1;
  font-size: 12px; cursor: pointer; padding: 0;
}
.pc-act:hover { background: var(--accent-bg); color: var(--accent); }

.save-prompt-box {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--separator);
}
.save-prompt-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.save-prompt-name {
  flex: 1 1 200px; min-width: 0; padding: 9px 12px;
  border: 1px solid var(--separator); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--surface); color: var(--label);
  font-family: inherit;
}
.save-prompt-name:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(197, 151, 42, 0.12); }
.save-prompt-type {
  padding: 9px 10px; border: 1px solid var(--separator); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--surface); color: var(--label2); font-family: inherit; cursor: pointer;
}
.save-prompt-type:focus { outline: none; border-color: var(--accent); }
.save-prompt-hint { margin-top: 8px; font-size: 12px; color: var(--label3); line-height: 1.5; }
@media (max-width: 520px) {
  .save-prompt-name, .save-prompt-type, .save-prompt-row .btn-secondary { flex: 1 1 100%; }
}
