/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-panel: #1a1d27;
  --bg-hover: #252836;
  --bg-input: #252836;
  --border: #2e3140;
  --text: #e4e6eb;
  --text-dim: #8b8fa3;
  --text-hint: #6b6f82;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --accent-bg: rgba(79, 140, 255, 0.1);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #ef4444;
  --radius: 8px;
  --radius-sm: 4px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.hidden { display: none !important; }

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.logo-accent { color: var(--accent); }
.logo-sub { font-size: 11px; color: var(--text-hint); }

.header-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  transition: all 0.15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--bg-hover);
}
.nav-external::after {
  content: ' \2197';
  font-size: 10px;
}

/* === Dropzone (inline in preview panel) === */
.dropzone-inline {
  text-align: center;
  padding: 48px 32px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-panel);
  max-width: 480px;
  width: 100%;
}
.dropzone-inline:hover, .dropzone-inline.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.dropzone-icon {
  color: var(--text-hint);
  margin-bottom: 16px;
  transition: color 0.2s;
}
.dropzone-inline:hover .dropzone-icon { color: var(--accent); }
.dropzone-text { font-size: 16px; margin-bottom: 8px; }
.dropzone-link { color: var(--accent); font-weight: 500; }
.dropzone-hint { font-size: 12px; color: var(--text-hint); }

/* === App Layout === */
.app { padding: 0; }
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  min-height: calc(100vh - 52px);
}

/* === Panels === */
.panel {
  padding: 20px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.panel:last-child { border-right: none; border-left: 1px solid var(--border); }
.panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-hint);
  margin-bottom: 20px;
}

.panel-settings { background: var(--bg-panel); }
.panel-preview { background: var(--bg); display: flex; flex-direction: column; }
.panel-export { background: var(--bg-panel); }

/* === Settings === */
.setting-group {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.setting-group:last-child { border-bottom: none; }
.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.setting-hint {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 6px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.setting-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* Video Info */
.video-info { margin-bottom: 8px; }
.video-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-meta { font-size: 11px; color: var(--text-hint); }

/* Size Grid */
.size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.size-btn {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
}
.size-btn:hover { border-color: var(--accent); color: var(--text); }
.size-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

/* Auto-detect banner */
.auto-detect {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--accent-bg);
  border: 1px solid rgba(79, 140, 255, 0.3);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.auto-detect-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-weight: 600;
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Custom saved sizes */
.custom-sizes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.custom-size-btn {
  padding: 6px 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.custom-size-btn:hover { border-color: var(--accent); color: var(--text); }
.custom-size-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}
.custom-size-rm {
  background: none;
  border: none;
  color: var(--text-hint);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.custom-size-rm:hover { color: var(--danger); }

.custom-size {
  display: flex;
  align-items: center;
  gap: 6px;
}
.size-x { color: var(--text-hint); font-size: 12px; }

/* Inputs */
.input, .select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
}
.input-small {
  width: 64px;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
  text-align: center;
}
.input-small:focus { outline: none; border-color: var(--accent); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%236b6f82' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* Color Options */
.color-options { display: flex; gap: 6px; align-items: center; }
.color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}
.color-btn:hover { border-color: var(--text-dim); }
.color-btn.active { border-color: var(--accent); }
.color-picker {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: none;
  padding: 0;
}

/* === Preview === */
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.preview-size {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-panel);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.preview-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.preview-container {
  position: relative;
  background: #000;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 2px;
  max-width: 100%;
  max-height: calc(100vh - 200px);
}

.preview-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-mute {
  position: absolute;
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s;
  /* width, height, top/left/right/bottom all set by JS */
}
.preview-mute:hover { background: rgba(0,0,0,0.8); }
.preview-mute svg { color: #fff; fill: #fff; }

.preview-click-overlay {
  position: absolute;
  inset: 0;
  cursor: pointer;
  z-index: 5;
}

.preview-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
}
.status-text { font-size: 12px; color: var(--success); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--border); }

.btn-small { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-secondary:hover { background: rgba(79, 140, 255, 0.2); }

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

/* === Batch Export === */
.batch-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}
.batch-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.1s;
}
.batch-item:hover { background: var(--bg-hover); }
.batch-item input { accent-color: var(--accent); }

/* === Code Preview === */
.code-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
  max-height: 300px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-all;
}

/* === Progress === */
.progress-area { margin-top: 16px; }
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}
.progress-text { font-size: 12px; color: var(--text-dim); }

/* === Validation === */
.validation-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.val-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.4;
  background: var(--bg);
}
.val-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  margin-top: 1px;
}
.val-pass .val-icon { background: rgba(52, 211, 153, 0.2); color: var(--success); }
.val-pass { color: var(--text-dim); }
.val-error .val-icon { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.val-error { color: var(--danger); }
.val-warn .val-icon { background: rgba(251, 191, 36, 0.2); color: var(--warning); }
.val-warn { color: var(--warning); }
.val-pending .val-icon { background: var(--bg-hover); color: var(--text-hint); }
.val-pending { color: var(--text-hint); }

/* === Content Sections === */
.content-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 60px 24px;
  border-top: 1px solid var(--border);
}
.content-section h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}
.content-section > p {
  color: var(--text-dim);
  margin-bottom: 32px;
}

/* Sizes Table */
.sizes-table { overflow-x: auto; }
.sizes-table table {
  width: 100%;
  border-collapse: collapse;
}
.sizes-table th, .sizes-table td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sizes-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-hint);
}
.sizes-table td:first-child {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}
.sizes-table tr:hover { background: var(--bg-panel); }

.use-size { visibility: hidden; }
.sizes-table tr:hover .use-size { visibility: visible; }

/* Docs Grid */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.doc-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.doc-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.doc-card p, .doc-card li {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.doc-card ul, .doc-card ol {
  padding-left: 20px;
  margin-top: 8px;
}
.doc-card li { margin-bottom: 4px; }
.doc-card pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
  font-size: 12px;
  overflow-x: auto;
}
.doc-card code {
  font-family: var(--mono);
  font-size: 12px;
}
.doc-card p code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}
.footer p { margin-bottom: 4px; }
.footer-privacy { font-size: 11px; color: var(--text-hint); }

/* === Template Gallery === */
.template-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.template-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
}
.template-card:hover { border-color: var(--accent); }
.template-card.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.template-thumb {
  height: 52px;
  padding: 4px;
}
.template-info {
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.template-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-cat {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

/* === Responsive === */
@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .panel { border-right: none; border-bottom: 1px solid var(--border); }
  .panel:last-child { border-left: none; }
  .panel-preview { min-height: 400px; }
}

@media (max-width: 640px) {
  .header { padding: 0 16px; }
  .header-nav { gap: 0; }
  .nav-link { padding: 6px 8px; font-size: 12px; }
  .dropzone-inline { padding: 32px 20px; }
  .docs-grid { grid-template-columns: 1fr; }
  .batch-list { grid-template-columns: 1fr; }
}
