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

:root {
  --bg: #fdf4ee;
  --bg-2: #fbe9df;
  --panel: #ffffff;
  --panel-2: #fdf1ea;
  --border: #f1ddd0;
  --border-strong: #e8c8b5;
  --text: #4a3a33;
  --heading: #3e2e2b;
  --muted: #a99287;
  --accent: #eb9d73;
  --accent-hover: #e5895a;
  --accent-soft: #fbe4d6;
  --error: #d97b6f;
  --ok: #5aa878;
  --shadow: 0 8px 30px rgba(160, 110, 80, 0.10);
  --shadow-sm: 0 2px 10px rgba(160, 110, 80, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--error); font-size: 14px; margin: 6px 0; }

/* ---------- Логин ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(1100px 600px at 50% -10%, var(--bg-2), var(--bg));
}
.login-decor {
  position: absolute;
  width: 620px; height: 620px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd9c2, transparent 62%),
              radial-gradient(circle at 70% 70%, #ffe9d6, transparent 60%);
  filter: blur(10px);
  opacity: .7;
  top: -180px; right: -160px;
  pointer-events: none;
}
.login-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 36px;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { width: 72px; height: 72px; margin: 0 auto 4px; }
.login-card h1 { font-size: 24px; color: var(--heading); font-weight: 700; }
.login-card > p { margin-bottom: 8px; font-size: 14px; }
.login-card label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--muted); text-align: left;
}

/* ---------- Поля ввода ---------- */
input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; line-height: 1.5; }

/* Стилизованные нативные select */
.dropdown-native { position: relative; }
.dropdown-native::after {
  content: "▾";
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); pointer-events: none; font-size: 12px;
}
.dropdown-native select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; }

/* ---------- Кнопки ---------- */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
  border-color: var(--accent-hover);
  color: #fff; font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { filter: brightness(1.04); }
.btn.primary:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); border-color: var(--border); color: var(--text); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.big { padding: 13px; font-size: 16px; }

/* ---------- Раскладка ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 410px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-header { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 40px; height: 40px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.brand-text b { color: var(--heading); font-size: 16px; }
.brand-text span { font-size: 12px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); }
.field-label { font-size: 13px; }
.row { display: flex; gap: 12px; }

.model-info {
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  line-height: 1.5;
}
.model-info .price { color: var(--ok); font-weight: 700; }

/* ---------- Кастомный выпадающий список моделей ---------- */
.dropdown { position: relative; }
.dropdown-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.dropdown-btn:hover { border-color: var(--accent); }
.dropdown-btn #model-dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-caret { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.dropdown-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  max-height: 380px;
  display: flex; flex-direction: column;
}
.dropdown-search { margin-bottom: 8px; }
.dropdown-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.dropdown-item {
  padding: 9px 11px;
  border-radius: 10px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.dropdown-item:hover { background: var(--panel-2); }
.dropdown-item.active { background: var(--accent-soft); }
.dropdown-item .di-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.dropdown-item .di-name { font-size: 14px; color: var(--heading); font-weight: 600; }
.dropdown-item .di-price { font-size: 13px; color: var(--ok); font-weight: 700; white-space: nowrap; }
.dropdown-item .di-desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Зона загрузки и превью ---------- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: var(--panel-2);
  transition: border-color .15s, background .15s;
}
.drop-zone.dragover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop-hint { display: block; font-size: 12px; margin-top: 4px; opacity: .8; }
.link { color: var(--accent-hover); cursor: pointer; text-decoration: underline; font-weight: 600; }

.previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.preview {
  position: relative;
  width: 86px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.preview .thumb { width: 86px; height: 66px; display: block; }
.preview .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview .pname {
  font-size: 10px; color: var(--muted);
  padding: 3px 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center;
}
.preview .remove {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(62, 46, 43, .72);
  color: #fff; border: none;
  font-size: 13px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Размер в пикселях ---------- */
.custom-size { display: flex; align-items: center; gap: 8px; }
.custom-size input { text-align: center; }
.custom-size .times { color: var(--muted); font-size: 16px; }
.custom-size .px { color: var(--muted); font-size: 13px; }

/* ---------- Стоимость ---------- */
.cost-box {
  background: linear-gradient(180deg, var(--accent-soft), var(--panel-2));
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 13px;
  font-size: 14px;
  line-height: 1.5;
}
.cost-box .sum { color: var(--accent-hover); font-weight: 800; font-size: 18px; }

.session-total { font-size: 13px; color: var(--muted); text-align: center; }
.session-total b { color: var(--heading); }

/* ---------- Результаты / история ---------- */
.results { flex: 1; padding: 26px 34px; max-width: 1000px; }
.results-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.results-head h2 { color: var(--heading); font-size: 22px; }
.results-list { display: flex; flex-direction: column; gap: 18px; }
.empty-hint { max-width: 520px; line-height: 1.6; }

.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.result-card .meta {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  font-size: 13px; color: var(--muted); margin-bottom: 10px;
}
.result-card .meta .model-name { color: var(--heading); font-weight: 600; }
.result-card .meta .cost { color: var(--ok); font-weight: 700; }
.result-card .prompt-text { font-size: 14px; margin-bottom: 12px; line-height: 1.5; color: var(--text); }
.result-images { display: flex; flex-wrap: wrap; gap: 14px; }
.result-img-wrap { display: flex; flex-direction: column; gap: 8px; }
.result-img-wrap img {
  max-width: 380px; max-height: 380px;
  border-radius: 12px; display: block;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.status-line { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Скроллбар в тёплых тонах */
.sidebar::-webkit-scrollbar, .dropdown-list::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .dropdown-list::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 8px;
}

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .results { padding: 20px; }
  .result-img-wrap img { max-width: 100%; }
}
