:root {
  /* Color Palette - Premium Flat Minimalist */
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #f8fafc;
  --secondary-hover: #f1f5f9;
  --bg-color: #f1f5f9; /* Clean flat light gray background */
  --panel-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  /* Radii */
  --radius-md: 0.375rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

/* Typography */
h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

/* Layout */
.app-container {
  display: flex;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  gap: 1.5rem;
  padding: 1.5rem;
}

@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }
}

/* Flat Panel Utilities */
.flat-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

/* Control Panel */
.control-panel {
  flex: 0 0 380px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: calc(100vh - 3rem);
  position: sticky;
  top: 1.5rem;
  overflow-y: auto;
}

@media (max-width: 900px) {
  .control-panel {
    flex: none;
    width: 100%;
    height: auto;
    position: static;
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

/* Form Controls */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.help-text {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

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

textarea {
  resize: vertical;
  min-height: 120px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn i {
  width: 1.1rem;
  height: 1.1rem;
}

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

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

.btn-primary:active {
  opacity: 0.9;
}

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

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

.btn-secondary:active {
  background: var(--border-color);
}

/* Workspace Area */
.workspace-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .workspace-area {
    width: 100%;
    margin-bottom: 2rem;
  }
}

/* Carousel Viewport */
.carousel-viewport {
  position: relative;
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
}

/* Carousel Container (Preview Container) */
.preview-container {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  width: 100%;
  gap: 0;
  scrollbar-width: none; /* Hide scrollbar for Firefox */
}

.preview-container::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari/Edge */
}

/* Carousel Slide Wrapper */
.preview-card-wrapper {
  flex: 0 0 100%;
  scroll-snap-align: center;
  box-sizing: border-box;
  padding: 0.25rem; /* Slight padding to avoid border cuts */
  display: flex;
  justify-content: center;
  background: transparent;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin {
  animation: spin 1s linear infinite;
}

/* Flat Preview Card (No shadows, flat border) */
.preview-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  max-width: 540px; /* Consistent card width */
  box-sizing: border-box;
}

.preview-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.preview-body {
  font-size: 1.25rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Carousel Navigation Buttons (Flat circular) */
.carousel-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
}

.carousel-nav-btn i {
  width: 1.25rem;
  height: 1.25rem;
}

.carousel-nav-btn:hover {
  background: var(--secondary-hover);
  border-color: #cbd5e1;
}

.carousel-nav-btn:active {
  background: #e2e8f0;
}

.carousel-nav-btn:disabled {
  opacity: 0;
  pointer-events: none;
}

#carousel-prev {
  left: -1.375rem;
}

#carousel-next {
  right: -1.375rem;
}

@media (max-width: 900px) {
  #carousel-prev {
    left: 0.5rem;
  }
  #carousel-next {
    right: 0.5rem;
  }
  .carousel-nav-btn {
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(255, 255, 255, 0.95);
  }
}

/* Carousel Dots Indicator */
.carousel-dots {
  display: flex;
  gap: 0.375rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.25rem;
}

.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.carousel-dot.active {
  background: var(--primary-color);
  width: 14px;
  border-radius: 3px;
}

/* Action Panel (Below Carousel) */
.action-panel {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-sizing: border-box;
}

.status-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 12px; /* Margin acts as gap only when message has content */
  transition: all 0.15s ease;
}

.status-msg:empty {
  height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.action-buttons {
  display: flex;
  gap: 15px; /* Nice unified gap for the actions */
  width: 100%;
}

.action-buttons .btn {
  flex: 1;
  width: 0;
}

/* Font Classes */
.font-gothic { font-family: 'Noto Sans JP', sans-serif; }
.font-mincho { font-family: 'Noto Serif JP', serif; }
.font-maru { font-family: 'Zen Maru Gothic', sans-serif; }
.font-handwriting { font-family: 'Yomogi', cursive; }

/* Aspect Ratios */
.aspect-square {
  aspect-ratio: 1 / 1;
  justify-content: center;
}
.aspect-portrait {
  aspect-ratio: 4 / 5;
  justify-content: center;
}
.aspect-landscape {
  aspect-ratio: 16 / 9;
  justify-content: center;
}
