:root {
  --bg: #14151a;
  --bg-card: #1e2028;
  --border: #2e3140;
  --text: #e8e9ed;
  --text-dim: #9497a8;
  --accent: #ffb400;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 20px;
  background: #1a1c24;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 1.3rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.form-panel label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.hint {
  display: block;
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 4px;
}

input[readonly] {
  opacity: 0.7;
  cursor: not-allowed;
}

.form-panel fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.form-panel legend {
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 0 6px;
}

.form-panel .checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 8px;
}

.form-panel .checkbox:last-child { margin-bottom: 0; }

.count-hint {
  color: var(--text-dim);
  font-size: 0.8em;
}

.module-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 10px;
  overflow: hidden;
}

.module-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
}

.module-row-header .checkbox {
  margin-bottom: 0;
  font-weight: 600;
}

.module-move {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.module-move button {
  padding: 2px 8px;
  font-size: 0.75rem;
  line-height: 1.4;
}

.module-move button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.module-settings {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.module-settings .row {
  margin-bottom: 10px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0f1015;
  color: var(--text);
  font-size: 0.95rem;
}

.url-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.color-row input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 2px;
  margin-top: 0;
  cursor: pointer;
}

.color-row button {
  padding: 8px 12px;
  font-size: 0.8rem;
}

.generated-url {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  /* Long URLs overflow the field — anchor the visible portion to the end
     (where the short /g/:id endpoint lives) instead of the start. */
  direction: rtl;
  text-align: left;
}

button, .url-row a {
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #14151a;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.url-row a {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

button:hover, .url-row a:hover { filter: brightness(1.1); }

button.copied { background: #8fe388; }

.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.preview-label {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.preview-stage {
  width: 100%;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #24262f 25%, transparent 25%),
    linear-gradient(-45deg, #24262f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #24262f 75%),
    linear-gradient(-45deg, transparent 75%, #24262f 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #1a1b21;
  border-radius: 8px;
  padding: 20px;
  overflow: auto;
}

.preview-window {
  overflow: hidden;
  flex-shrink: 0;
  background-image: url('../assets/background.jpg');
  background-repeat: repeat;
  background-size: 220px 220px;
  background-color: #ffffff;
}

.preview-window iframe {
  border: 0;
  display: block;
}

.preview-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.preview-actions .hint {
  color: var(--text-dim);
  max-width: 420px;
}
