[hidden] {
  display: none !important;
}

﻿/* ==========================================================================
   Lumiere AI Studio - Design System & Stylesheet
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-hover: #059669;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #93c5fd;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft JhengHei", sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.app-header {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.nav-tabs {
  display: flex;
  gap: 6px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 18px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--primary);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.gallery-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-line-id {
  font-size: 11px;
  color: var(--text-light);
  font-family: monospace;
}

.quota-pill-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.quota-pill-header.empty {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* --- Guest Banner --- */
.guest-banner {
  background: linear-gradient(90deg, #eff6ff, #f0fdf4);
  border-bottom: 1px solid #dbeafe;
  padding: 10px 24px;
}

.banner-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: #1e3a8a;
  flex-wrap: wrap;
}

.banner-badge {
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: #cbd5e1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  border-color: var(--success-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-line {
  background: #06c755;
  border-color: #06c755;
  color: #fff;
  font-weight: 600;
}

.btn-line:hover {
  background: #05b04b;
  border-color: #05b04b;
}

.btn-icon {
  padding: 8px;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.btn-text:hover {
  background: var(--primary-light);
}

.btn-block {
  width: 100%;
}

/* --- Main Layout --- */
.app-main {
  flex: 1;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

/* --- Workspace Grid --- */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.25fr) minmax(360px, 0.95fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.quota-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.quota-pill.exhausted {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-group .required {
  color: var(--danger);
  font-style: normal;
}

.form-control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.char-count {
  font-size: 11px;
  color: var(--text-light);
}

.prompt-textarea {
  height: 120px;
  resize: vertical;
  line-height: 1.5;
}

/* --- Prompt Presets Bar --- */
.presets-section {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.presets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.presets-header label {
  margin-bottom: 0;
  font-size: 12px;
}

.presets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  align-items: center;
}

.presets-empty {
  font-size: 12px;
  color: var(--text-light);
  font-style: italic;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 3px 8px 3px 10px;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.preset-chip .chip-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-chip .chip-del {
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.preset-chip .chip-del:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* --- Reference Uploads --- */
.upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--bg-main);
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.upload-box:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.ref-previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ref-card {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.ref-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ref-card .btn-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Generate Action Area --- */
.gen-action-area {
  margin-top: 20px;
}

.btn-generate {
  width: 100%;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transition: all 0.15s ease;
}

.btn-generate:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-generate:disabled {
  background: #cbd5e1;
  box-shadow: none;
  cursor: not-allowed;
}

.cost-estimate-box {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 10px;
  text-align: center;
}

.estimate-cost {
  font-size: 13px;
  color: var(--text-main);
}

.estimate-cost strong {
  color: var(--primary);
  font-size: 15px;
}

.estimate-tip {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* --- Results Panel --- */
.status-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.status-idle {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.status-working {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.status-done {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.status-fail {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.canvas-container {
  min-height: 360px;
  background: var(--bg-main);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}

.canvas-placeholder {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
}

.canvas-placeholder p {
  font-size: 13px;
  margin-top: 8px;
  max-width: 260px;
}

.result-image {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
}

.canvas-spinner {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.task-info-card {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.info-label {
  color: var(--text-muted);
}

.info-value {
  font-weight: 600;
}

.info-value.mono {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- VIEW 2: Cropper Tool --- */
.cropper-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cropper-toolbar {
  padding: 14px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.segmented-control {
  display: inline-flex;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
}

.segment-btn {
  background: transparent;
  border: none;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segment-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tool-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.crop-dimension-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.badge-ratio {
  font-size: 11px;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.cropper-stage {
  min-height: 520px;
  background: #0f172a;
  background-image: 
    linear-gradient(45deg, #1e293b 25%, transparent 25%), 
    linear-gradient(-45deg, #1e293b 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #1e293b 75%), 
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
  user-select: none;
}

.crop-stage-empty {
  text-align: center;
  color: #94a3b8;
}

.crop-stage-empty h3 {
  font-size: 16px;
  margin: 12px 0 4px;
  color: #e2e8f0;
}

.crop-stage-empty p {
  font-size: 13px;
}

.crop-canvas-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.crop-target-image {
  display: block;
  max-width: 100%;
  max-height: 580px;
  pointer-events: none;
}

/* Crop Mask and Box */
.crop-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 2;
}

.crop-selection-box {
  position: absolute;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  z-index: 5;
  touch-action: none;
}

/* Rule of Thirds Grid */
.crop-grid-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grid-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.35);
}

.grid-line.h1 { top: 33.333%; left: 0; right: 0; height: 1px; }
.grid-line.h2 { top: 66.666%; left: 0; right: 0; height: 1px; }
.grid-line.v1 { left: 33.333%; top: 0; bottom: 0; width: 1px; }
.grid-line.v2 { left: 66.666%; top: 0; bottom: 0; width: 1px; }

/* 8 Resize Handles */
.c-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #38bdf8;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.c-handle.nw { left: -7px; top: -7px; cursor: nwse-resize; }
.c-handle.n  { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }
.c-handle.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.c-handle.e  { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.c-handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.c-handle.s  { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.c-handle.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.c-handle.w  { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

/* --- VIEW 3: Gallery --- */
.gallery-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.gallery-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.gallery-header-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.gallery-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.gallery-filter span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.gallery-filter .form-control {
  min-height: 36px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.gallery-results-bar {
  color: var(--text-muted);
  font-size: 12px;
  min-height: 18px;
}

.gallery-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.gallery-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-media {
  height: 200px;
  background: #0f172a;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.media-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 12px;
  background: #0f172a;
}

.card-media.is-error .media-loading {
  color: #fca5a5;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.card-media:hover img {
  transform: scale(1.04);
}

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-model-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
}

.card-cost-badge {
  font-size: 11px;
  font-weight: 600;
  background: #ecfdf5;
  color: #065f46;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-date {
  font-size: 11px;
  color: var(--text-light);
}

.card-prompt {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.card-btn {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.card-btn:hover {
  background: var(--bg-elevated);
  color: var(--primary);
  border-color: #cbd5e1;
}

.card-btn.btn-del:hover {
  color: var(--danger);
  background: #fef2f2;
}

.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.gallery-empty h3 {
  font-size: 17px;
  margin: 12px 0 6px;
}

.gallery-empty p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .gallery-header {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery-header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .gallery-filter {
    min-width: 0;
  }

  .gallery-header-actions .btn {
    justify-content: center;
  }
}

/* --- Modals --- */
.modal-overlay[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 460px;
  width: 100%;
  overflow: hidden;
  animation: modalIn 0.15s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px;
  background: var(--bg-main);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Login Modal */
.login-modal-body {
  text-align: center;
}

.login-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.login-modal-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.point-rate-card {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: left;
  font-size: 12px;
  color: var(--text-main);
  line-height: 1.6;
  margin-bottom: 20px;
}

.btn-line-large {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  background: #06c755;
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background 0.15s ease;
}

.btn-line-large:hover {
  background: #05b04b;
}

/* Lightbox Modal */
.lightbox-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  max-width: 960px;
  width: 100%;
  max-height: 85vh;
  display: grid;
  grid-template-columns: 1fr 340px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-media-wrapper {
  background: #090d16;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.lightbox-media-wrapper img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

.lightbox-sidebar {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
}

.lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.date-badge {
  font-size: 11px;
  color: var(--text-muted);
}

.lightbox-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.prompt-box {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 13px;
  max-height: 150px;
  overflow-y: auto;
  line-height: 1.5;
}

.spec-text, .mono-text {
  font-size: 13px;
  font-weight: 500;
}

.mono-text {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.lightbox-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.2s ease;
}

.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .lightbox-card {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow-y: auto;
  }
  .lightbox-media-wrapper {
    height: 320px;
  }
  .cropper-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 12px;
  }
  .header-left {
    gap: 12px;
  }
  .nav-tab {
    padding: 16px 8px;
    font-size: 13px;
  }
  .result-actions {
    grid-template-columns: 1fr;
  }
}

/* --- Visual refresh --- */
body {
  background: var(--bg-main);
}

.app-header {
  height: 70px;
  padding: 0 clamp(16px, 3vw, 36px);
  box-shadow: 0 1px 0 rgba(148, 163, 184, 0.25), 0 8px 24px rgba(15, 23, 42, 0.04);
}

.header-left {
  gap: clamp(16px, 3vw, 38px);
  min-width: 0;
}

.brand {
  flex: 0 0 auto;
  letter-spacing: 0;
}

.nav-tabs {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  border-bottom: 0;
  border-radius: 8px;
  padding: 10px 12px;
  white-space: nowrap;
}

.nav-tab:hover {
  background: #f1f5f9;
}

.nav-tab.active {
  background: var(--primary-light);
}

.guest-banner {
  background: #eef6ff;
  border-bottom-color: #d7e7fb;
}

.app-main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 32px) clamp(14px, 3vw, 36px);
}

.workspace-grid {
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 24px;
}

.panel {
  border-color: #d8e2ee;
  border-radius: 10px;
  padding: clamp(18px, 2.4vw, 28px);
  box-shadow: 0 12px 30px rgba(30, 64, 175, 0.06);
}

.panel-header {
  margin-bottom: 22px;
  padding-bottom: 14px;
}

.panel-header h2 {
  letter-spacing: 0;
}

.form-control {
  border-color: #d4deea;
  min-height: 42px;
}

.form-control:hover {
  border-color: #b8c7d9;
}

.presets-section,
.cost-estimate-box,
.task-info-card {
  background: #f6f9fc;
}

.btn {
  min-height: 38px;
  border-radius: 8px;
}

.btn-primary,
.btn-success,
.btn-generate {
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.16);
}

/* Cropper workspace */
.cropper-container {
  border-color: #d8e2ee;
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.07);
}

.cropper-toolbar {
  padding: 16px clamp(16px, 2.5vw, 24px);
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.96);
}

.toolbar-left,
.toolbar-right {
  align-items: center;
}

.cropper-toolbar-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 150px;
  margin-right: 4px;
}

.toolbar-eyebrow,
.crop-empty-kicker {
  color: #0f766e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.cropper-toolbar-title strong {
  color: var(--text-main);
  font-size: 15px;
  font-weight: 750;
}

.btn-upload-crop {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding-inline: 15px;
  color: #fff !important;
  font-size: 14px !important;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
}

.btn-upload-crop svg,
#btn-crop-confirm-download svg {
  display: block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: currentColor;
  stroke: currentColor;
}

#btn-crop-confirm-download {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  color: #fff !important;
  font-size: 14px !important;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
}

.ratio-preset-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented-control {
  background: #f3f7fb;
  border-color: #d5e0eb;
}

#cropper-ratio-group {
  max-width: min(100%, 640px);
  flex-wrap: wrap;
}

.segment-btn {
  min-height: 29px;
  white-space: nowrap;
}

.crop-dimension-display {
  padding: 7px 10px;
  border: 1px solid #d8e2ee;
  border-radius: 8px;
  background: #f8fafc;
  white-space: nowrap;
}

.cropper-stage {
  min-height: clamp(540px, calc(100vh - 260px), 760px);
  padding: clamp(18px, 4vw, 42px);
  background-color: #101c2d;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.crop-stage-empty {
  width: min(100%, 460px);
  padding: 38px 34px 32px;
  border: 1px solid rgba(191, 219, 254, 0.2);
  border-radius: 14px;
  background: rgba(15, 31, 52, 0.86);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.crop-empty-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 18px;
  color: #7dd3fc;
  background: rgba(14, 116, 144, 0.18);
}

.crop-empty-kicker {
  display: block;
  margin-bottom: 7px;
}

.crop-stage-empty h3 {
  margin: 0 0 8px;
  color: #f8fafc;
  font-size: clamp(19px, 2vw, 23px);
}

.crop-stage-empty p {
  max-width: 320px;
  margin: 0 auto 20px;
  color: #b9c7d8;
  line-height: 1.6;
}

.crop-upload-dropzone {
  min-height: 136px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed rgba(125, 211, 252, 0.72);
  border-radius: 12px;
  color: #bae6fd;
  background: rgba(14, 165, 233, 0.09);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.crop-upload-dropzone:hover,
.crop-upload-dropzone.is-dragging {
  border-color: #38bdf8;
  background: rgba(14, 165, 233, 0.2);
  transform: translateY(-2px);
}

.crop-upload-dropzone strong {
  color: #f8fafc;
  font-size: 14px;
}

.crop-upload-dropzone span {
  color: #9fb2c8;
  font-size: 12px;
}

.crop-upload-note {
  display: block;
  margin-top: 14px;
  color: #8295aa;
  font-size: 11px;
}

.crop-canvas-wrapper {
  max-width: 100%;
  border: 1px solid rgba(226, 232, 240, 0.2);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
}

.crop-target-image {
  max-width: 100%;
  max-height: min(620px, calc(100vh - 330px));
}

.crop-selection-box {
  border-color: #67e8f9;
  box-shadow: 0 0 0 9999px rgba(3, 10, 20, 0.62);
}

.c-handle {
  background: #67e8f9;
}

@media (max-width: 1100px) {
  .cropper-toolbar {
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

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

  .cropper-toolbar-title {
    margin-right: auto;
  }
}

@media (max-width: 900px) {
  .app-header {
    height: auto;
    min-height: 64px;
    padding-block: 8px;
  }

  .header-left {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .nav-tab {
    padding: 8px 10px;
  }

  .cropper-stage {
    min-height: 500px;
  }

  .cropper-toolbar-title {
    min-width: 130px;
  }
}

@media (max-width: 600px) {
  .header-right {
    gap: 6px;
  }

  .guest-banner {
    padding-inline: 14px;
  }

  .banner-content {
    align-items: flex-start;
  }

  .cropper-toolbar {
    padding: 14px;
  }

  .toolbar-left,
  .toolbar-right,
  .ratio-preset-group {
    align-items: stretch;
  }

  .cropper-toolbar-title,
  .btn-upload-crop,
  .ratio-preset-group,
  .tool-btn-group,
  .toolbar-right,
  .crop-dimension-display,
  #btn-crop-confirm-download {
    width: 100%;
  }

  .toolbar-left,
  .toolbar-right {
    flex-direction: column;
  }

  .ratio-preset-group {
    flex-direction: column;
  }

  .segmented-control {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .tool-btn-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .toolbar-right {
    gap: 10px;
  }

  .crop-dimension-display {
    justify-content: space-between;
  }

  .crop-stage-empty {
    padding: 30px 18px 24px;
  }

  .cropper-stage {
    min-height: 460px;
    padding: 16px;
  }
}

/* --- Final contrast and polish pass --- */
:root {
  --primary: #075985;
  --primary-hover: #0c4a6e;
  --primary-light: #e0f2fe;
  --bg-main: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-elevated: #e8eef5;
  --border: #d5e0ea;
  --border-focus: #38bdf8;
  --text-main: #102a43;
  --text-muted: #52677d;
  --text-light: #8295a8;
}

body {
  color: var(--text-main);
  background: #f1f5f9;
}

.app-header {
  background: rgba(255, 255, 255, 0.98);
  border-bottom-color: #cbd8e5;
}

.brand,
.brand-icon {
  color: #075985;
}

.nav-tab {
  color: #52677d;
}

.nav-tab:hover {
  color: #075985;
  background: #e0f2fe;
}

.nav-tab.active {
  color: #075985;
  background: #e0f2fe;
}

.guest-banner {
  background: #e0f2fe;
  border-bottom-color: #bae6fd;
}

.banner-content {
  color: #164e63;
}

.panel,
.cropper-container,
.gallery-card {
  border-color: #d5e0ea;
  box-shadow: 0 10px 28px rgba(30, 64, 91, 0.08);
}

.panel-header {
  border-bottom-color: #e2eaf1;
}

.form-control {
  background: #ffffff;
  border-color: #cbd8e5;
}

.form-control:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

.btn {
  border-color: #cbd8e5;
  background: #ffffff;
  color: #183b56;
}

.btn:hover:not(:disabled) {
  background: #f0f7fb;
  border-color: #94aabd;
}

.btn-primary {
  background: #075985;
  border-color: #075985;
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: #0c4a6e;
  border-color: #0c4a6e;
}

.btn-success {
  background: #047857;
  border-color: #047857;
  color: #ffffff;
}

.btn-success:hover:not(:disabled) {
  background: #065f46;
  border-color: #065f46;
}

.btn-generate {
  background: #075985;
  box-shadow: 0 8px 18px rgba(7, 89, 133, 0.22);
}

.btn-generate:hover:not(:disabled) {
  background: #0c4a6e;
  box-shadow: 0 10px 22px rgba(7, 89, 133, 0.28);
}

.btn-upload-crop,
#btn-crop-confirm-download {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px !important;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
}

.btn-upload-crop {
  background: #075985 !important;
  border: 1px solid #075985 !important;
  color: #ffffff !important;
  cursor: pointer;
}

.btn-upload-crop:hover {
  background: #0c4a6e !important;
  border-color: #0c4a6e !important;
}

#btn-crop-confirm-download {
  background: #047857 !important;
  border: 1px solid #047857 !important;
  color: #ffffff !important;
}

#btn-crop-confirm-download:hover:not(:disabled) {
  background: #065f46 !important;
  border-color: #065f46 !important;
}

#btn-crop-confirm-download:disabled {
  background: #94a3b8 !important;
  border-color: #94a3b8 !important;
  color: #f8fafc !important;
  opacity: 0.9;
}

.btn-upload-crop > span,
#btn-crop-confirm-download > span {
  display: inline-block;
  color: inherit !important;
  visibility: visible !important;
}

.btn-upload-crop svg,
#btn-crop-confirm-download svg {
  display: block !important;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: currentColor !important;
  stroke: currentColor !important;
  visibility: visible !important;
}

.cropper-toolbar {
  background: #ffffff;
  border-bottom-color: #d5e0ea;
}

.cropper-toolbar-title strong {
  color: #102a43;
}

.toolbar-eyebrow,
.crop-empty-kicker {
  color: #0f766e;
}

.segmented-control {
  background: #f1f5f9;
  border-color: #cbd8e5;
}

.segment-btn {
  color: #52677d;
}

.segment-btn:hover {
  color: #075985;
  background: #e0f2fe;
}

.segment-btn.active {
  color: #075985;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(30, 64, 91, 0.16);
}

.crop-dimension-display {
  color: #183b56;
  background: #f8fafc;
  border-color: #cbd8e5;
}

.badge-ratio {
  color: #52677d;
  background: #e8eef5;
}

.cropper-stage {
  background-color: #0b1f33;
}

.crop-stage-empty {
  background: #102a43;
  border-color: rgba(125, 211, 252, 0.32);
}

.crop-upload-dropzone {
  color: #bae6fd;
  background: rgba(2, 132, 199, 0.16);
  border-color: #38bdf8;
}

.crop-upload-dropzone:hover,
.crop-upload-dropzone.is-dragging {
  background: rgba(2, 132, 199, 0.28);
  border-color: #7dd3fc;
}

.crop-selection-box {
  border-color: #67e8f9;
}

.toast {
  border: 1px solid rgba(255, 255, 255, 0.14);
}

@media (max-width: 600px) {
  .btn-upload-crop,
  #btn-crop-confirm-download {
    width: 100%;
  }
}
