/* ============================================
   GPT2IMAGE — Design Tokens & Stylesheet
   Clean light theme with Claude elegance
   All sizes at 125% scale (×1.25 from base)
   ============================================ */

:root {
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-tertiary: #ececf1;
  --bg-hover: #f0f0f3;
  --bg-chat-user: #f7f7f8;
  --bg-chat-ai: #ffffff;

  /* Borders */
  --border: #d9d9e3;
  --border-subtle: #e8e8ed;

  /* Text */
  --text-primary: #1a1a1a;
  --text-secondary: #555568;
  --text-tertiary: #8e8ea0;
  --text-muted: #b4b4c4;

  /* Accent */
  --accent: #1a1a1a;

  /* Radii (×1.25) */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Typography */
  --font-serif: 'Libre Baskerville', 'Noto Serif SC', 'Source Han Serif SC', Georgia, serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ---- Base Reset ---- */

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Typography ---- */

h1, h2 {
  font-family: var(--font-serif);
  font-weight: 500;
}

/* ---- Layout Classes ---- */

.view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.view-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* ---- Header ---- */

.header {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  height: 70px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  z-index: 100;
}

.header-logo {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
}

.header-logo-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.header-logo-text {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.header-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.header-icon-btn {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.header-icon-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.header-icon-btn[data-action="menu"] {
  display: none;
}

.header-tabs {
  display: flex;
  flex-direction: row;
  gap: 2px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
}

/* ---- Mobile Menu ---- */

.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 8px 15px;
  flex-direction: column;
  gap: 2px;
  z-index: 99;
}

.mobile-menu.open {
  display: flex;
}

.mobile-menu-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.mobile-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.mobile-menu-item.active {
  color: var(--text-primary);
  font-weight: 500;
  background: var(--bg-secondary);
}

.tab {
  padding: 5px 15px;
  border-radius: 10px;
  font-size: 16px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.tab.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.tab:hover {
  color: var(--text-secondary);
}

/* ---- Settings Form ---- */

.settings-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 500px;
  margin: 0 auto;
}

.settings-github {
  position: fixed;
  top: 20px;
  right: 20px;
  color: var(--text-muted);
  transition: color var(--transition-fast);
  z-index: 10;
}

.settings-github:hover {
  color: var(--text-primary);
}

/* Settings — Full (connected) */

.settings-full {
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.settings-full-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 32px;
}

.settings-section {
  margin-bottom: 32px;
}

.settings-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}

.settings-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-toggle-name {
  font-size: 15px;
  color: var(--text-primary);
}

.settings-toggle-desc {
  font-size: 13px;
  color: var(--text-tertiary);
}

.settings-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
}

.settings-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.settings-footer-link:hover {
  color: var(--text-primary);
}

/* Toggle Switch */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 12px;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.settings-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  margin-bottom: 10px;
}

.settings-subtitle {
  color: var(--text-tertiary);
  font-size: 17px;
  margin-bottom: 40px;
}

.form-group {
  margin-bottom: 24px;
}

.form-label {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  display: block;
}

.form-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 17px;
  font-size: 17px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
  font-family: inherit;
}

.form-input:focus {
  border-color: #8e8ea0;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--bg-primary);
  padding: 15px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition-fast);
}

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

.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---- Options Row ---- */

.options-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px;
}

/* ---- Ghost Dropdown (Thinking) ---- */

.ghost-dropdown {
  position: relative;
}

.ghost-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.ghost-dropdown-trigger:hover,
.ghost-dropdown-trigger.open {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.ghost-dropdown-prefix {
  margin-right: 2px;
}

.ghost-dropdown-value {
  font-weight: 500;
  color: var(--text-secondary);
}

.ghost-dropdown-trigger:hover .ghost-dropdown-value,
.ghost-dropdown-trigger.open .ghost-dropdown-value {
  color: var(--text-primary);
}

.ghost-dropdown-arrow {
  display: flex;
  align-items: center;
  transition: transform var(--transition-fast);
}

.ghost-dropdown-trigger.open .ghost-dropdown-arrow {
  transform: rotate(180deg);
}

.ghost-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 120px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 4px;
  z-index: 200;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.ghost-dropdown-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ghost-dropdown-item {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.ghost-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ghost-dropdown-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
}

/* ---- Size Dropdown ---- */

.size-dropdown {
  position: relative;
}

.size-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.size-dropdown-trigger:hover {
  border-color: #8e8ea0;
  background: transparent;
}

.size-dropdown-trigger.open {
  border-color: #8e8ea0;
  background: transparent;
}

.size-dropdown-arrow {
  display: flex;
  align-items: center;
  transition: transform var(--transition-fast);
}

.size-dropdown-trigger.open .size-dropdown-arrow {
  transform: rotate(180deg);
}

.size-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 4px;
  z-index: 200;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.size-dropdown-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.size-dropdown-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.size-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.size-dropdown-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
}

.size-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px;
  justify-content: flex-end;
}

.size-custom-input {
  width: 80px;
  padding: 5px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  -moz-appearance: textfield;
}

.size-custom-input::-webkit-outer-spin-button,
.size-custom-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.size-custom-input:focus {
  border-color: #8e8ea0;
}

.size-custom-x {
  font-size: 14px;
  color: var(--text-tertiary);
}

.size-custom-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Input Bar ---- */

.input-bar {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 17px;
}

.input-bar-text {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 17px;
  outline: none;
  resize: none;
  overflow: hidden;
  font-family: inherit;
  line-height: 1.4;
}

.input-bar-text::placeholder {
  color: var(--text-muted);
}

.input-bar-attach {
  width: 34px;
  height: 34px;
  border: 1px dashed #c4c4d0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  background: transparent;
}

.input-bar-attach:hover {
  border-color: #8e8ea0;
  color: var(--text-secondary);
}

.input-bar-send {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-primary);
  cursor: pointer;
  border: none;
  transition: opacity var(--transition-fast);
}

.input-bar-send:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: default;
}

/* ---- Message Actions ---- */

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

.message-retry {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.message-retry:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.variant-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.variant-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.variant-nav-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.variant-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ---- Chat ---- */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.message {
  max-width: 65%;
  display: flex;
  flex-direction: column;
}

.message-ai .image-card {
  max-width: 280px;
}

.message-ai .image-card img {
  max-width: 280px;
  height: auto;
}

.message-user {
  align-self: flex-end;
}

.message-ai {
  align-self: flex-start;
  max-width: 85%;
}

.bubble-user {
  background: var(--bg-chat-user);
  border-radius: 18px 18px 5px 18px;
  padding: 12px 17px;
  font-size: 17px;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.bubble-ai {
  background: var(--bg-chat-ai);
  border-radius: var(--radius-lg);
  padding: 12px;
  border: 1px solid var(--border-subtle);
}

.bubble-ai-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  word-break: break-word;
  font-family: var(--font-serif);
  letter-spacing: 0.01em;
}

/* ---- Markdown Body ---- */
.markdown-body p { margin: 0 0 10px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 16px 0 8px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}
.markdown-body h1 { font-size: 1.4em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body h3 { font-size: 1.1em; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 1em; }
.markdown-body ul, .markdown-body ol {
  margin: 8px 0;
  padding-left: 24px;
}
.markdown-body li { margin: 4px 0; }
.markdown-body code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.markdown-body pre {
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
}
.markdown-body blockquote {
  margin: 10px 0;
  padding: 4px 16px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}
.markdown-body table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.9em;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: left;
}
.markdown-body th {
  background: var(--bg-secondary);
  font-weight: 600;
}
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.markdown-body strong { font-weight: 600; }
.markdown-body a { color: var(--text-primary); text-decoration: underline; }

/* ---- Thinking Block ---- */

.thinking-block {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 10px;
}

.thinking-summary {
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  list-style: none;
}

.thinking-summary::-webkit-details-marker {
  display: none;
}

.thinking-summary::before {
  content: '▶ ';
  font-size: 10px;
  transition: transform var(--transition-fast);
  display: inline-block;
  margin-right: 4px;
}

.thinking-block[open] .thinking-summary::before {
  content: '▼ ';
}

.thinking-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

/* ---- Image Card ---- */

.image-card {
  position: relative;
  overflow: hidden;
  border-radius: 15px;
  cursor: pointer;
}

.image-card img {
  display: block;
  width: 100%;
  border-radius: 15px;
}

.image-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity var(--transition-normal);
  display: flex;
}

.image-card:hover .image-card-overlay {
  opacity: 1;
}

.image-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 5px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.image-card-btn {
  position: absolute;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.image-card-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.3);
}

.image-card-btn.download {
  top: 10px;
  right: 10px;
}

.image-card-btn.edit {
  bottom: 10px;
  left: 10px;
  width: auto;
  padding: 0 12px;
  gap: 5px;
  font-size: 14px;
}

.image-card-btn.fullscreen {
  bottom: 10px;
  right: 10px;
}

/* ---- Landing Hero ---- */

.landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 24px;
}

.landing-logo {
  height: 60px;
  object-fit: contain;
}

.landing-title {
  font-family: var(--font-serif);
  font-size: 35px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.landing-subtitle {
  font-size: 17px;
  color: var(--text-tertiary);
  margin-top: -10px;
}

.landing-input {
  width: 100%;
  max-width: 700px;
  margin-top: 10px;
}

.suggestion-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 10px;
}

.chip {
  padding: 6px 15px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 15px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.chip:hover {
  border-color: var(--border);
  color: var(--text-secondary);
}

.recent-row {
  margin-top: 30px;
  text-align: center;
}

.recent-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.recent-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.recent-thumb {
  width: 75px;
  height: 75px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  cursor: pointer;
}

.recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Gallery Grid ---- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 15px;
  padding: 20px 24px;
}

.gallery-grid .image-card img {
  max-height: 300px;
  object-fit: cover;
}

/* ---- History List ---- */

.history-list {
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
}

.history-item {
  display: flex;
  gap: 15px;
  align-items: center;
  padding: 15px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.history-item:hover {
  background: var(--bg-hover);
}

.history-thumb {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  background: var(--bg-secondary);
  overflow: hidden;
  flex-shrink: 0;
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-text {
  flex: 1;
  overflow: hidden;
}

.history-prompt {
  font-size: 17px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 3px;
}

.history-delete {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  background: transparent;
  border: none;
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
}

/* ---- Lightbox ---- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: var(--radius-lg);
  object-fit: contain;
}

.lightbox-prompt {
  margin-top: 20px;
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 750px;
  text-align: center;
}

/* ---- Toast ---- */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 20px;
  font-size: 16px;
  color: var(--text-secondary);
  transform: translateX(120%);
  transition: transform 300ms ease;
  max-width: 440px;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  border-color: #b53333;
}

/* ---- Loading Animation ---- */

.loading-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #8e8ea0;
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ---- View Transitions ---- */

.fade-in {
  animation: fadeIn var(--transition-slow);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Scrollbar (WebKit) ---- */

::-webkit-scrollbar {
  width: 7px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

/* ---- Error Color ---- */

.bubble-ai-error {
  color: #b53333;
}

/* ---- Dark Theme ---- */

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2e2e2e;
  --bg-hover: #333333;
  --bg-chat-user: #242424;
  --bg-chat-ai: #1a1a1a;
  --border: #3a3a3a;
  --border-subtle: #2e2e2e;
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --text-muted: #555555;
  --accent: #e8e8e8;
}

[data-theme="dark"] .header-logo-icon,
[data-theme="dark"] .landing-logo,
[data-theme="dark"] .settings-view img {
  filter: invert(1);
}

[data-theme="dark"] .bubble-ai-error {
  color: #e05555;
}

[data-theme="dark"] .toggle-slider::before {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ---- Responsive ---- */

@media (max-width: 640px) {
  .header {
    padding: 0 15px;
  }

  .header-logo-text {
    display: none;
  }

  .header-tabs {
    display: none;
  }

  .header-icon-btn[data-action="menu"] {
    display: flex;
  }

  .header-btn-label {
    display: none;
  }

  .landing-title {
    font-size: 27px;
  }

  .landing-subtitle {
    font-size: 15px;
  }

  .suggestion-chips {
    gap: 6px;
  }

  .chip {
    font-size: 13px;
    padding: 5px 10px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  }

  .chat-messages {
    padding: 15px;
  }

  .message {
    max-width: 85%;
  }

  .message-ai {
    max-width: 95%;
  }
}
