:root {
  --bg: #0b0d14;
  --panel: #111827;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --accent-2: #3b82f6;
  --white-card: #f9fafb;
  --black-card: #0b0d14;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 24px;
}

body.modal-open {
  overflow: hidden;
}

button, input, textarea {
  font-family: inherit;
}

.app-shell {
  width: min(1200px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 20px 20px 28px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.keyboard-hint {
  justify-self: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.actions { justify-self: end; }

.layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.maker {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
}

.card-stage {
  background: #0f1624;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.card {
  width: 380px;
  height: 530px;
  border-radius: 22px;
  padding: 24px;
  position: relative;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, color 150ms ease;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.card.card-white {
  background: var(--white-card);
  color: #0f1624;
}

.card.card-black {
  background: var(--black-card);
  color: #f9fafb;
}

.card-chip {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: inherit;
  opacity: 0.65;
}

.card-text {
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 18px;
  flex: 1;
  word-break: break-word;
  overflow: hidden;
  text-align: left;
}

.card-ghost {
  display: none;
}

.card.wiggle {
  animation: wiggle 320ms ease;
}

.card-stage:focus-within .card-ghost,
.card:hover .card-ghost {
  opacity: 0.8;
}

@keyframes wiggle {
  0% { transform: translateY(0); }
  35% { transform: translateY(-6px) rotate(-1deg); }
  70% { transform: translateY(2px) rotate(1deg); }
  100% { transform: translateY(0); }
}

.color-toggle {
  display: flex;
  gap: 12px;
}

.pill {
  border: 1px solid var(--border);
  background: #1f2937;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.pill:hover { background: #273345; }

.input-panel {
  background: #0f1624;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.label { color: var(--muted); font-size: 0.9rem; }

textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0b0f1a;
  color: var(--text);
  font-size: 1rem;
  resize: none;
  min-height: 110px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.4);
}

.actions-row { display: flex; gap: 10px; align-items: center; }

button {
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
}

button:active { transform: translateY(1px); }

.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
}

.primary:hover { filter: brightness(1.05); }

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.primary:disabled:hover {
  filter: grayscale(0.5);
}

.ghost {
  background: #111827;
  color: var(--text);
  border: 1px solid var(--border);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stack {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
  min-height: 100%;
}

.stack-header { font-weight: 600; letter-spacing: 0.01em; }

.help-panel {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0f1624;
  display: grid;
  gap: 10px;
}

.help-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.help-display {
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: #0b0f1a;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
}

.stack-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #0f1624;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.stack-card .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.help-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.help-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.stack-card .text { color: var(--text); }

.stack-list.empty { color: var(--muted); }

.tooltip {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translateX(-50%) translateY(-50%) scale(0.95);
  width: min(600px, 90%);
  background: #111827;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  padding: 18px;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 160ms ease;
}

.tooltip.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-50%) scale(1);
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.tooltip-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.tooltip-body {
  display: grid;
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
}

.shortcut-group h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shortcut-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.shortcut-item:last-child {
  border-bottom: none;
}

.key {
  display: inline-block;
  padding: 4px 8px;
  background: #1f2937;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: monospace;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  color: var(--text);
}

.desc {
  color: var(--muted);
  font-size: 0.95rem;
}



.manage {
  position: fixed;
  inset: 12% auto auto 50%;
  transform: translateX(-50%) translateY(20px);
  width: min(1300px, 95%);
  max-height: 80vh;
  background: #111827;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  padding: 18px;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 160ms ease;
  display: flex;
  flex-direction: column;
}

.manage.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.manage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0; font-size: 0.8rem; }

.manage h2 { margin: 4px 0 0; }

.manage-body { display: flex; gap: 12px; overflow: hidden; flex: 1; min-height: 0; }

.carousel-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}

.carousel-card {
  width: 380px;
  height: 530px;
  border-radius: 22px;
  padding: 24px;
  position: relative;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  margin: 0 auto;
  overflow: hidden;
  text-align: left;
}

.carousel-card > div {
  max-height: 100%;
  overflow: hidden;
  text-align: left;
}

.carousel-card.white {
  background: var(--white-card);
  color: #0f1624;
}

.carousel-card.black {
  background: var(--black-card);
  color: var(--white-card);
}

.carousel-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.carousel-btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #1f2937;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease;
}

.carousel-btn:hover {
  background: #273345;
}

.carousel-counter {
  text-align: center;
  flex: 1;
  color: var(--muted);
  font-size: 0.9rem;
}

.manage-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.manage input[type="search"] {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b0f1a;
  color: var(--text);
}

.filters { display: flex; gap: 8px; }

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: #1f2937;
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
}

.chip.active { border-color: var(--accent); color: var(--accent); }

.manage-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0f1624;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}

.row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: #111827;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms ease;
}

.row:hover {
  background: #1a2332;
}

.row.active {
  background: #1f2937;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3);
}

.row-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.row-text { color: var(--text); }

.row-meta { color: var(--muted); font-size: 0.9rem; }

.help-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.85rem;
  margin-right: 8px;
}

.row-actions button { padding: 8px 10px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0b0f1a;
  color: #e5e7eb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  body { padding: 12px; }
  .layout { grid-template-columns: 1fr; }
  .maker { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr; }
  .keyboard-hint { justify-self: start; }
}
