:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2f3d;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --success: #34a853;
  --error: #ea4335;
  --warning: #fbbc04;
}

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

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

input[type="file"] {
  padding: 0.5rem;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#submit-btn {
  width: 100%;
}

.hidden {
  display: none !important;
}

.badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  background: var(--border);
}

.badge.running {
  background: rgba(251, 188, 4, 0.15);
  color: var(--warning);
}

.badge.done {
  background: rgba(52, 168, 83, 0.15);
  color: var(--success);
}

.badge.failed {
  background: rgba(234, 67, 53, 0.15);
  color: var(--error);
}

.log-container {
  max-height: 320px;
  overflow-y: auto;
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}

.log-entry:last-child {
  border-bottom: none;
}

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

.log-time {
  color: var(--muted);
  font-size: 0.75rem;
}

.result {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(52, 168, 83, 0.1);
  border-radius: 8px;
  border: 1px solid var(--success);
}

.result a {
  color: var(--accent);
  word-break: break-all;
}

.downloads {
  margin-top: 1rem;
}

.downloads a {
  display: inline-block;
  margin: 0.25rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
}

.telethon-card h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.telethon-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.telethon-form input {
  flex: 1;
  min-width: 120px;
}

.telethon-form button {
  flex-shrink: 0;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.65rem;
  font-size: 0.9rem;
}

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

.sticker-list {
  margin-top: 1rem;
  max-height: 280px;
  overflow-y: auto;
}

.sticker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.btn-delete {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

.btn-delete:hover {
  background: rgba(234, 67, 53, 0.1);
}

#pack-info {
  margin-top: 1rem;
}

#pack-info p {
  margin-bottom: 0.5rem;
}

.face-preview {
  margin: 0.75rem 0;
  text-align: center;
}

.face-preview img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 12px;
  border: 2px solid var(--border);
  object-fit: cover;
}

.ai-mode-toggle {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.ai-mode-toggle label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--text);
}

.models-section {
  margin: 1.25rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.models-section h3 {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.model-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.model-row .model-name {
  flex: 1;
  min-width: 100px;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.model-row .model-id {
  flex: 2;
  min-width: 160px;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.btn-delete-model {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  flex-shrink: 0;
}

#add-model-btn {
  margin-bottom: 1rem;
}

.prompt-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.prompt-block textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  margin-left: 0.5rem;
  margin-bottom: 1rem;
}

.btn-delete-prompt {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

#save-prompts-btn {
  width: 100%;
}

select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.model-hint {
  color: var(--accent);
  font-weight: 600;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.gallery-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.gallery-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.gallery-card-preview {
  position: relative;
  aspect-ratio: 1;
  background: #1e2230;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-card-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.gallery-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.gallery-card-info {
  padding: 0.75rem;
}

.gallery-card-info strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.gallery-card-info small {
  color: var(--muted);
  font-size: 0.78rem;
}

.gallery-pack-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--accent);
}

.gallery-thumbs {
  display: flex;
  gap: 0.35rem;
  padding: 0 0.75rem 0.75rem;
  overflow-x: auto;
}

.gallery-thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: #1e2230;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}

.gallery-thumb:hover {
  border-color: var(--accent);
}

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

.lightbox.hidden {
  display: none !important;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}

.lightbox-content img {
  max-width: 85vw;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: -2.5rem;
  left: 0;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

#lightbox-caption {
  color: #ccc;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.lightbox-download {
  display: inline-block;
  margin-top: 0.75rem;
  color: var(--accent);
}
