:root {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --accent-color: #10b981;
  --accent-hover: #059669;

  /* Dynamic Card Theme variables (overridden via JS) */
  --card-bg: #f4f8fb;
  --card-text: #1c2d42;
  --card-primary: #0f4c81;
  --card-secondary: #e5a93b;
  --card-font: 'Inter', sans-serif;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2rem;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-back {
  color: #4fd1c5;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 4px 8px;
  border: 1px solid #1e2c42;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-back:hover {
  background: #0f172a;
  border-color: #4fd1c5;
}

.logo-icon {
  font-size: 2rem;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.75rem;
  background: #334155;
  color: #38bdf8;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* LAYOUT */
.app-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  flex: 1;
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text-main);
}

/* FORM STYLES */
.form-group {
  margin-bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"], select, textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.tone-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tone-chip {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: #0f172a;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tone-chip:hover {
  border-color: var(--primary-color);
  color: var(--text-main);
}

.tone-chip.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
  font-weight: 500;
}

/* BUTTONS */
.btn {
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #334155;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #475569;
}

.btn-accent {
  background: var(--accent-color);
  color: white;
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-large {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  margin-top: 0.5rem;
}

/* PREVIEW SECTION */
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.view-mode-toggle {
  display: flex;
  background: #0f172a;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.toggle-btn {
  background: none;
  border: none;
  padding: 0.4rem 0.8rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}

.toggle-btn.active {
  background: #334155;
  color: var(--text-main);
  font-weight: 500;
}

/* CARD STAGE & CANVAS */
.card-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  min-height: 440px;
  overflow: auto;
}

.card-container {
  font-family: var(--card-font);
  color: var(--card-text);
  transition: all 0.3s ease;
}

/* SPREAD VIEW (Inside Left + Right) */
.card-spread-view {
  display: flex;
  width: 640px;
  height: 420px;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.1);
  position: relative;
}

.card-spread-view::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(0, 0, 0, 0.08);
  box-shadow: inset 1px 0 2px rgba(0,0,0,0.1);
}

.card-panel {
  flex: 1;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.inside-left {
  background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(0,0,0,0.02) 100%);
  border-right: 1px dashed rgba(0,0,0,0.15);
  align-items: center;
  justify-content: center;
  text-align: center;
}

.panel-watermark {
  width: 80px;
  height: 80px;
  color: var(--card-primary);
  opacity: 0.85;
  margin-bottom: 1.5rem;
}

.card-quote {
  font-size: 1.1rem;
  font-style: italic;
  color: var(--card-primary);
  line-height: 1.5;
  max-width: 85%;
  outline: none;
  padding: 4px;
  border-radius: 4px;
}

.card-quote:hover, .card-message:hover, .cover-headline:hover, .cover-subtitle:hover, .card-signature:hover {
  background: rgba(59, 130, 246, 0.08);
  outline: 1px dashed var(--primary-color);
}

.inside-right {
  justify-content: space-between;
}

.card-message {
  font-size: 1rem;
  line-height: 1.65;
  white-space: pre-line;
  outline: none;
  padding: 4px;
  border-radius: 4px;
}

.card-signature {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--card-primary);
  align-self: flex-end;
  text-align: right;
  white-space: pre-line;
  outline: none;
  padding: 4px;
  border-radius: 4px;
}

/* COVER VIEW */
.card-cover-view {
  width: 340px;
  height: 460px;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.6);
  border: 1px solid rgba(0,0,0,0.1);
  display: flex;
}

.front-cover {
  width: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.6), transparent 70%);
  border: 8px solid var(--card-primary);
  border-radius: 6px;
  margin: 12px;
}

.cover-art {
  width: 90px;
  height: 90px;
  color: var(--card-primary);
  margin-bottom: 1.5rem;
}

.cover-headline {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--card-primary);
  margin-bottom: 0.8rem;
  line-height: 1.3;
  outline: none;
  padding: 4px;
}

.cover-subtitle {
  font-size: 1rem;
  color: var(--card-text);
  opacity: 0.9;
  outline: none;
  padding: 4px;
}

/* ACTION BAR */
.action-bar {
  margin-top: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.hint-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.action-buttons {
  display: flex;
  gap: 0.8rem;
}

/* PRINT MEDIA STYLES (4-Panel Printable Card Layout) */
@media print {
  body * {
    visibility: hidden;
  }
  
  #printView, #printView * {
    visibility: visible;
  }

  #printView {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    color: black;
  }

  .print-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    width: 100%;
    height: 100%;
    border: 1px solid #ccc;
  }

  .print-panel {
    padding: 2rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 1px dashed #ddd;
  }

  .back-cover {
    transform: rotate(180deg);
  }

  .front-cover-print {
    transform: rotate(180deg);
  }

  .cover-art-sm {
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
  }
}
