﻿/* ============================================
   Image Essential - Image Editor
   style.css - Complete Stylesheet
   ============================================ */

/* ===== CSS Variables ===== */
:root {
  --primary: #03406c;
  --primary-hover: #022a4b;
  --bg-color: #02182b;
  --text-main: #ffffff;
  --text-muted: #d0d7e2;
  --card-bg: #ffffff;
  --card-text: #111827;
  --card-muted: #6b7280;
  --border-radius: 12px;
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.45);
  --crop-overlay-color: rgba(0, 0, 0, 0.6);
  --handle-size: 16px;
  --badge-green-bg: #e6f9ec;
  --badge-green-text: #12823b;
  --btn-radius: 999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(circle at top, #063970 0, #02182b 45%, #010712 100%);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ===== Header ===== */
header {
  text-align: center;
  padding: 1rem 1rem 0.5rem;
}

.logo-img {
  max-height: 40px;
  margin-bottom: 0.25rem;
}

h1 {
  font-size: 1.2rem;
  font-weight: 800;
}

h1 span {
  padding: 0.05rem 0.5rem;
  margin-left: 0.2rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.5);
  font-size: 0.7rem;
}

p.subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  max-width: 620px;
  margin: 0.2rem auto 0;
}

.tools-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s;
}

.tools-link:hover {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(148, 163, 184, 0.7);
}

/* ===== Main Layout ===== */
main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
  align-items: start;
  width: 100%;
}

.preview-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sidebar {
  position: sticky;
  top: 12px;
  align-self: start;
}

/* ===== Upload Zone (Legacy) ===== */
.upload-zone {
  background: rgba(15, 23, 42, 0.9);
  border: 1px dashed rgba(148, 163, 184, 0.7);
  border-radius: 18px;
  padding: 2.4rem 1.4rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: 1.6rem;
  position: relative;
  transition: all 0.3s ease;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: #e5e7eb;
  background: rgba(15, 23, 42, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.upload-zone input {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-text {
  font-size: 1rem;
  font-weight: 600;
  color: #e5e7eb;
}

.upload-subtext {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

/* ===== Editor Section ===== */
#editor-section {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.6rem 1.4rem 1.8rem;
  box-shadow: var(--shadow);
  color: var(--card-text);
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  min-height: 40px;
  background: linear-gradient(135deg, #1e293b, #0f172a, #1e293b);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  position: relative;
}

.tab-bar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(148, 163, 184, 0.3) 20%, rgba(148, 163, 184, 0.3) 80%, transparent);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  user-select: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 200px;
  position: relative;
  animation: tabSlideIn 0.3s ease-out;
}

@keyframes tabSlideIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tab-btn .tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}

.tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(255, 255, 255, 0.9);
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.5);
}

.tab-btn.active .tab-name {
  color: #0f172a;
}

/* ===== Tab Close Button ===== */
.tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.5);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.tab-close:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
  transform: scale(1.2);
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.4);
}

.tab-close:active {
  transform: scale(0.9);
}

.tab-btn.active .tab-close {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.4);
  border-color: rgba(0, 0, 0, 0.1);
}

.tab-btn.active .tab-close:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.4);
}

/* ===== Tab Add Button ===== */
.tab-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.45);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1;
}

.tab-add:hover {
  border-color: rgba(96, 165, 250, 0.5);
  color: rgba(255, 255, 255, 0.8);
  background: rgba(96, 165, 250, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tab-add:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ===== Cropper Wrapper (Image Preview Area) ===== */
.cropper-wrapper {
  position: relative;
  background: #ffffff;
  border-radius: 0;
  overflow: hidden;
  margin-bottom: 1.5rem;
  user-select: none;
  max-height: 75vh;
  min-height: 200px;
  flex: 1;
}

.cropper-wrapper.upload-zone-empty {
  background: linear-gradient(145deg, #050d1a 0%, #010814 45%, #000204 100%);
  border: 2px dashed rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 2.4rem 2rem;
  min-height: 300px;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.5), 0 8px 32px rgba(0, 0, 0, 0.3);
}

.cropper-wrapper.upload-zone-empty #image-preview,
.cropper-wrapper.upload-zone-empty #sticker-layer,
.cropper-wrapper.upload-zone-empty #crop-overlay,
.cropper-wrapper.upload-zone-empty #crop-info,
.cropper-wrapper.upload-zone-empty .opacity-panel,
.cropper-wrapper.upload-zone-empty .tab-close-btn {
  display: none !important;
}

.cropper-wrapper.upload-zone-empty .upload-placeholder {
  display: flex !important;
}

.cropper-wrapper.upload-zone-empty:hover {
  border-color: rgba(148, 163, 184, 0.4);
  background: linear-gradient(145deg, #081222 0%, #020a18 45%, #000408 100%);
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.55), 0 12px 40px rgba(0, 0, 0, 0.4);
}

.cropper-wrapper.upload-zone-empty.drag-over {
  border-color: rgba(96, 165, 250, 0.5);
  background: linear-gradient(145deg, #0a1525 0%, #030b1a 45%, #010509 100%);
  box-shadow: inset 0 0 100px rgba(59, 130, 246, 0.05), 0 0 40px rgba(59, 130, 246, 0.08);
}

/* ===== Upload Placeholder (Empty State) ===== */
.upload-placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 1rem;
  text-align: center;
  pointer-events: auto;
}

.upload-empty-icon {
  font-size: 2.8rem;
  line-height: 1;
  opacity: 0.8;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.upload-empty-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f0f4ff;
  letter-spacing: 0.02em;
}

.upload-empty-sub {
  font-size: 0.85rem;
  color: rgba(209, 213, 219, 0.7);
  margin-top: 2px;
}

.upload-empty-sub kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 0.7rem;
  color: #d1d5db;
}

.upload-empty-browse {
  background: none;
  border: none;
  color: #93c5fd;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
  transition: color 0.15s;
}

.upload-empty-browse:hover {
  color: #bfdbfe;
}

.upload-empty-hints {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
  font-size: 0.75rem;
  color: rgba(156, 163, 175, 0.6);
}

/* ===== Preview Image ===== */
#image-preview {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  pointer-events: none;
  margin: 0 auto;
}

/* ===== Sticker / Overlay Layer ===== */
#sticker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

.overlay-img {
  position: absolute;
  cursor: move;
  pointer-events: auto;
  display: none;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.overlay-text {
  position: absolute;
  cursor: move;
  pointer-events: auto;
  display: none;
  padding: 2px 4px;
  white-space: pre;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0);
}

/* ===== Sticker Handles ===== */
.sticker-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border: 1px solid #0f172a;
  border-radius: 4px;
  z-index: 40;
  pointer-events: auto;
  display: none;
}

.sh-nw { cursor: nw-resize; }
.sh-ne { cursor: ne-resize; }
.sh-sw { cursor: sw-resize; }
.sh-se { cursor: se-resize; }
.sh-n  { cursor: n-resize; }
.sh-s  { cursor: s-resize; }
.sh-w  { cursor: w-resize; }
.sh-e  { cursor: e-resize; }

/* ===== Overlay List ===== */
.overlay-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overlay-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.overlay-item:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.overlay-item.active {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
  background: #ffffff;
}

/* ===== Overlay Actions ===== */
.overlay-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.overlay-actions button {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: #111827;
  transition: all 0.2s ease;
}

.overlay-actions button:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.overlay-actions button:active {
  transform: translateY(0);
}

.overlay-actions input[type="range"] {
  width: 70px;
}

/* ===== Text Controls ===== */
.text-controls {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.text-controls .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.text-controls .row.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.text-controls .mini-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 4px;
}

.text-controls textarea {
  min-height: 70px;
  resize: vertical;
  width: 100%;
}

/* ===== Color Swatch ===== */
.color-swatch {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-swatch:hover {
  border-color: #d1d5db;
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== Toggle Row ===== */
.toggle-row {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

/* ===== Text Actions ===== */
.text-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.text-actions button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: #111827;
  transition: all 0.2s ease;
}

.text-actions button:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.text-actions button:active {
  transform: translateY(0);
}

/* ===== Opacity Label & Panel ===== */
.opacity-label {
  font-weight: 700;
  color: #111827;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.opacity-panel {
  margin-top: 6px;
  padding: 8px;
  border: 1px dashed #e5e7eb;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  display: none;
}

/* ===== Crop Overlay ===== */
#crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  box-shadow: 0 0 0 9999px var(--crop-overlay-color);
  display: none;
}

#crop-box {
  position: absolute;
  border: 1px solid #f9fafb;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.55);
  cursor: move;
  display: none;
  z-index: 10;
  touch-action: none;
  pointer-events: auto;
}

.crop-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.4;
}

.crop-grid::before,
.crop-grid::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #f9fafb;
}

.crop-grid::before { left: 33.33%; }
.crop-grid::after { right: 33.33%; }

.grid-h-1,
.grid-h-2 {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #f9fafb;
}

.grid-h-1 { top: 33.33%; }
.grid-h-2 { bottom: 33.33%; }

/* ===== Crop Handles ===== */
.handle {
  position: absolute;
  width: var(--handle-size);
  height: var(--handle-size);
  background: #f9fafb;
  border: 1px solid #0f172a;
  border-radius: 6px;
  z-index: 20;
  touch-action: none;
  pointer-events: auto;
}

.h-nw { top: -8px; left: -8px; cursor: nw-resize; }
.h-ne { top: -8px; right: -8px; cursor: ne-resize; }
.h-sw { bottom: -8px; left: -8px; cursor: sw-resize; }
.h-se { bottom: -8px; right: -8px; cursor: se-resize; }
.h-n  { top: -8px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.h-s  { bottom: -8px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.h-w  { top: 50%; left: -8px; transform: translateY(-50%); cursor: w-resize; }
.h-e  { top: 50%; right: -8px; transform: translateY(-50%); cursor: e-resize; }

/* ===== Sidebar Sections ===== */
.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--card-muted);
  margin: 0.7rem 0 0.4rem;
  letter-spacing: 0.04em;
}

.section-list > li {
  list-style: none;
  background: #fafbfc;
  border: 1px solid #eef0f2;
  border-radius: 12px;
  padding: 10px 12px;
  transition: all 0.2s ease;
}

.section-list > li:hover {
  border-color: #e2e5e9;
  background: #fbfdff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.section-list > li:has(.chip-label.active),
.section-list > li:has(.ratio-btn.active) {
  border-color: rgba(99, 102, 241, 0.2);
  background: rgba(99, 102, 241, 0.02);
}

.section-list > li.span-2 {
  grid-column: 1 / -1;
}

/* ===== Crop Mode Chips ===== */
.chip-bar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  background: #f1f3f5;
  padding: 0.45rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #e8eaed;
}

.chip-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: #4b5563;
  user-select: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.chip-label input { display: none; }

.chip-label.active {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #f9fafb;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2), 0 0 20px rgba(15, 23, 42, 0.08);
}

.chip-label:hover:not(.active) {
  background: #e5e7eb;
  color: #111827;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.chip-label:active:not(.active) {
  transform: translateY(0);
}

/* ===== Aspect Ratio Presets ===== */
.ratio-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #e2e5e9;
  background: #ffffff;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  color: #4b5563;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ratio-btn.active {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #f9fafb;
  border-color: #0f172a;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2), 0 0 16px rgba(15, 23, 42, 0.08);
}

.ratio-btn:hover:not(.active) {
  background: #f3f4f6;
  border-color: #9ca3af;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ===== Quick Action Buttons ===== */
.news-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--btn-radius);
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
  animation: newsGlow 3s ease-in-out infinite;
}

@keyframes newsGlow {
  0%, 100% { box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3); }
  50% { box-shadow: 0 4px 24px rgba(5, 150, 105, 0.5), 0 0 40px rgba(5, 150, 105, 0.12); }
}

.news-quick-btn:hover {
  background: linear-gradient(135deg, #10b981, #059669);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4);
  animation: none;
}

/* ===== Sidebar Grid Layout ===== */
.section-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.section-list > li {
  list-style: none;
}

.section-list > li.span-2 {
  grid-column: 1 / -1;
}

.control-group {
  margin-bottom: 0.4rem;
}

.control-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #4b5563;
}

.sidebar .section-title {
  font-size: 0.7rem;
  margin-top: 0.35rem;
}

.sidebar .control-group label {
  font-size: 0.7rem;
  margin-bottom: 3px;
}

.sidebar select,
.sidebar input[type="text"],
.sidebar input[type="color"],
.sidebar textarea {
  font-size: 0.75rem;
  padding: 6px 7px;
}

.sidebar input[type="range"] {
  font-size: 0.75rem;
}

.sidebar .inline-panel-title,
.sidebar .inline-panel-toggle {
  font-size: 0.7rem;
}

.sidebar .inline-panel-toggle {
  padding: 4px 8px;
}

/* ===== Form Elements ===== */
select,
input[type="text"] {
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid #e5e7eb;
  font-size: 0.9rem;
  background: #f9fafb;
  transition: all 0.2s ease;
}

select:hover,
input[type="text"]:hover {
  border-color: #d1d5db;
}

select:focus,
input[type="text"]:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
  background: #ffffff;
}

/* ===== Range Slider ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  margin: 8px 0;
  outline: none;
  border: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  border: none;
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  border: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border: 2px solid #4338ca;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-top: -6px;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 6px rgba(67, 56, 202, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #ffffff;
  border: 2px solid #4338ca;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 6px rgba(67, 56, 202, 0.2);
}

input[type="range"]:focus {
  outline: none;
}

/* ===== Filename Input ===== */
#rename-input {
  font-weight: 700;
  background: #eef2ff;
  border-color: #c7d2fe;
}

.blink-highlight {
  animation: blinkGlow 1s linear infinite;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

@keyframes blinkGlow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
  50% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.35); }
}

.filename-priority {
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 14px 28px rgba(99, 102, 241, 0.14);
}

.filename-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.filename-blink {
  animation: filenamePulse 1.2s ease-in-out infinite;
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

@keyframes filenamePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
  50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.28); }
}

/* ===== Format Select ===== */
.format-inline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

#format-select {
  border: 1px solid #e2e5e9;
  background: #ffffff;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#format-select:hover {
  border-color: #6366f1;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

#format-select:focus {
  border-color: #4338ca;
  box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
}

.badge-green {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, #e6f9ec, #d1fae5);
  color: #047857;
  border: 1px solid rgba(4, 120, 87, 0.15);
}

/* ===== Size Display ===== */
.size-display {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #0f172a;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  background: linear-gradient(135deg, #eff6ff, #eef2ff);
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(99, 102, 241, 0.08);
}

.size-status {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
}

.size-ok {
  color: #15803d;
  background: rgba(21, 128, 61, 0.08);
}

.size-warn {
  color: #b45309;
  background: rgba(180, 83, 9, 0.08);
}

/* ===== Toolbar ===== */
.toolbar-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
  background: #f8f9fa;
  border: 1px solid #eef0f2;
  border-radius: 12px;
  padding: 6px 8px;
}

.toolbar-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid #e2e5e9;
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: #1e293b;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.toolbar-btn:hover {
  background: #ffffff;
  border-color: #6366f1;
  color: #4338ca;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15), 0 0 20px rgba(99, 102, 241, 0.06);
}

.toolbar-btn:active {
  background: #eef2ff;
  transform: translateY(0);
  box-shadow: none;
}

.toolbar-btn.active {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #f9fafb;
  border-color: #0f172a;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.toolbar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Action Buttons (bottom) ===== */
.actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.4rem;
  flex-wrap: wrap;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #f9fafb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  animation: btnPulse 2.5s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25); }
  50% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.45), 0 0 40px rgba(37, 99, 235, 0.1); }
}

/* ===== Inline Panels ===== */
.inline-panel {
  margin-top: 1rem;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px;
}

.inline-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inline-panel-title {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 0.08em;
}

.inline-panel-toggle {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: #111827;
  transition: all 0.2s ease;
}

.inline-panel-toggle:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.inline-panel-body {
  margin-top: 10px;
}

.inline-panel.compact {
  max-width: 100%;
}

.inline-panel.compact .text-controls {
  gap: 6px;
}

.inline-panel.compact .row {
  gap: 6px;
}

.inline-panel.compact label {
  font-size: 0.7rem;
}

.inline-panel.compact select,
.inline-panel.compact input[type="text"],
.inline-panel.compact textarea,
.inline-panel.compact input[type="color"] {
  padding: 6px 7px;
  font-size: 0.74rem;
}

.inline-panel.compact input[type="range"] {
  font-size: 0.74rem;
}

/* ===== Optional Section ===== */
.optional-section {
  border: 1px dashed #e5e7eb;
  border-radius: 10px;
  padding: 8px;
  background: #ffffff;
}

.optional-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.optional-header label {
  font-weight: 700;
  color: #111827;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #374151;
}

/* ===== Button Styles ===== */
.btn {
  flex: 1;
  min-width: 130px;
  padding: 0.8rem 1.1rem;
  border: none;
  border-radius: var(--btn-radius);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

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

.btn:not(:disabled):active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #f9fafb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f3f4f6;
  color: #111827;
  border: 1px solid #e5e7eb;
}

.btn-secondary:not(:disabled):hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.btn-ghost {
  background: transparent;
  color: #111827;
  border: 1px dashed #d1d5db;
}

.btn-ghost:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

/* ===== Crop Info Badge ===== */
#crop-info {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(15, 23, 42, 0.7);
  color: #f9fafb;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  pointer-events: none;
  z-index: 15;
  display: none;
}

/* ===== Toast Notifications ===== */
#toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.toast {
  background: #111827;
  color: #e5e7eb;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.8rem;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Floating Preview ===== */
.floating-preview {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 220px;
  max-width: 60vw;
  aspect-ratio: 4 / 3;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.2);
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  z-index: 1500;
  display: none;
  touch-action: none;
  cursor: grab;
  transition: box-shadow 0.2s ease;
}

.floating-preview:hover {
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.25);
}

.floating-preview.dragging {
  cursor: grabbing;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.3);
}

.floating-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.75rem;
  font-weight: 700;
  color: #111827;
  user-select: none;
}

.floating-preview img {
  width: 100%;
  height: calc(100% - 28px);
  object-fit: contain;
  display: block;
  background: #ffffff;
}

.floating-resizer {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border-right: 3px solid #6b7280;
  border-bottom: 3px solid #6b7280;
  cursor: nwse-resize;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.3rem 1rem 1.6rem;
  color: rgba(209, 213, 219, 0.7);
  font-size: 0.75rem;
  margin-top: auto;
}

/* ===== Loading Indicator ===== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.loading-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Keyboard Shortcuts Hint ===== */
.keyboard-hint {
  font-size: 0.65rem;
  color: #9ca3af;
  margin-top: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.keyboard-hint kbd {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 0.7rem;
}

/* ===== Tab Close Button (Image Area) ===== */
.tab-close-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 50;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #6b7280;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.tab-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {
  header { padding: 0.875rem 0.75rem 0.4rem; }
  h1 { font-size: 1.15rem; }
  h1 span { font-size: 0.7rem; padding: 0.05rem 0.4rem; }
  p.subtitle { font-size: 0.8rem; }

  main { padding: 0.75rem; }

  .workspace {
    grid-template-columns: 1fr;
    gap: 0.875rem;
  }

  .sidebar { position: static; order: 2; }
  .preview-panel { order: 1; }

  #editor-section {
    padding: 1.25rem 1rem 1.5rem;
    border-radius: 10px;
  }

  .tab-bar {
    gap: 5px;
    margin-bottom: 12px;
    padding: 5px;
    border-radius: 10px;
  }

  .tab-btn {
    padding: 6px 11px;
    font-size: 0.73rem;
    max-width: 150px;
  }

  .tab-add {
    padding: 6px 11px;
    font-size: 1rem;
  }

  .toolbar-row {
    gap: 5px;
    margin-bottom: 6px;
  }

  .toolbar-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
    min-height: 36px;
  }

  .cropper-wrapper {
    max-height: 65vh;
    margin-bottom: 1rem;
    border-radius: 10px;
  }

  .cropper-wrapper.upload-zone-empty {
    padding: 1.5rem 1rem;
    min-height: 240px;
    gap: 6px;
  }

  .upload-empty-icon { font-size: 2.2rem; }
  .upload-empty-title { font-size: 1rem; }
  .upload-empty-sub { font-size: 0.78rem; }
  .upload-empty-hints { gap: 12px; font-size: 0.7rem; }

  .section-list { grid-template-columns: 1fr; gap: 0.75rem; }

  .section-title { font-size: 0.75rem; margin: 0.5rem 0 0.25rem; }

  .control-group { margin-bottom: 0.35rem; }
  .control-group label { font-size: 0.75rem; margin-bottom: 4px; }

  .chip-bar { padding: 0.4rem 0.5rem; gap: 0.35rem; }
  .chip-label { padding: 4px 9px; font-size: 0.75rem; }
  .ratio-btn { padding: 3px 7px; font-size: 0.68rem; }

  .actions { gap: 0.6rem; margin-top: 1.25rem; }
  .btn { min-width: 100px; padding: 0.75rem 1rem; font-size: 0.85rem; }

  .floating-preview { width: 180px; max-width: 50vw; }

  :root { --handle-size: 22px; }
  .keyboard-hint { display: none; }

  .tab-close-btn {
    width: 24px;
    height: 24px;
    top: 6px;
    left: 6px;
    font-size: 0.9rem;
  }
}

/* ===== Responsive: Small Mobile ===== */
@media (max-width: 480px) {
  header { padding: 0.75rem 0.5rem 0.35rem; }
  h1 { font-size: 1.05rem; }
  h1 span { display: none; }
  p.subtitle { font-size: 0.75rem; margin-top: 0.2rem; }

  main { padding: 0.625rem; }

  #editor-section {
    padding: 1rem 0.875rem 1.25rem;
    border-radius: 8px;
  }

  .tab-bar {
    gap: 4px;
    margin-bottom: 10px;
    padding: 4px;
    border-radius: 8px;
  }

  .tab-btn {
    padding: 5px 9px;
    font-size: 0.7rem;
    max-width: 110px;
  }

  .tab-add {
    padding: 5px 9px;
    font-size: 0.9rem;
  }

  .toolbar-row {
    gap: 4px;
    margin-bottom: 5px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .toolbar-btn {
    padding: 5px 9px;
    font-size: 0.68rem;
    min-height: 34px;
    flex: 0 1 auto;
  }

  .cropper-wrapper { max-height: 60vh; border-radius: 8px; }

  .cropper-wrapper.upload-zone-empty {
    padding: 1.25rem 0.875rem;
    min-height: 200px;
  }

  .upload-empty-icon { font-size: 1.8rem; }
  .upload-empty-title { font-size: 0.9rem; }
  .upload-empty-sub { font-size: 0.72rem; }
  .upload-empty-hints { gap: 10px; font-size: 0.68rem; }

  .section-list { gap: 0.625rem; }
  .section-title { font-size: 0.7rem; }
  .control-group label { font-size: 0.72rem; }

  .sidebar select,
  .sidebar input[type="text"],
  .sidebar input[type="color"],
  .sidebar textarea {
    font-size: 0.7rem;
    padding: 5px 6px;
    min-height: 36px;
  }

  .sidebar input[type="range"] {
    font-size: 0.7rem;
    min-height: 36px;
  }

  .chip-bar { padding: 0.35rem 0.45rem; gap: 0.3rem; }
  .chip-label { padding: 3px 8px; font-size: 0.7rem; }
  .ratio-btn { padding: 2px 6px; font-size: 0.65rem; }

  .actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn {
    min-width: 100%;
    padding: 0.7rem 1rem;
    font-size: 0.82rem;
  }

  .inline-panel { padding: 10px; border-radius: 10px; }
  .inline-panel-title { font-size: 0.75rem; }
  .inline-panel-toggle { padding: 5px 10px; font-size: 0.7rem; }

  .text-controls { padding: 8px; gap: 6px; }
  .text-controls .row { gap: 6px; }
  .optional-section { padding: 6px; }

  .floating-preview {
    width: 160px;
    max-width: 45vw;
    right: 8px;
    bottom: 8px;
  }

  .floating-preview-header { padding: 5px 7px; font-size: 0.7rem; }

  .toast { padding: 9px 16px; font-size: 0.75rem; }

  :root { --handle-size: 26px; }

  .tab-close-btn {
    width: 22px;
    height: 22px;
    top: 5px;
    left: 5px;
    font-size: 0.85rem;
  }
}

/* ===== Touch Device Optimization ===== */
@media (hover: none) and (pointer: coarse) {
  .toolbar-btn { min-height: 40px; min-width: 44px; }
  .tab-btn { min-height: 40px; }
  .tab-close { min-width: 28px; min-height: 28px; }
  .ratio-btn { min-height: 36px; padding: 6px 10px; }
  .chip-label { min-height: 38px; }
  .btn { min-height: 44px; }
  select, input[type="text"], input[type="range"] { min-height: 40px; }

  .sidebar select,
  .sidebar input[type="text"],
  .sidebar input[type="range"],
  .sidebar input[type="color"],
  .sidebar textarea {
    min-height: 40px;
  }
}

/* ===== Accessibility: Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== All Tools Dropdown ===== */
.tools-menu-wrap {
  position: relative;
  display: inline-block;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 12px rgba(119, 8, 30, 0.3); }
  50% { box-shadow: 0 4px 24px rgba(255, 50, 50, 0.7), 0 0 0 4px rgba(255, 50, 50, 0.15); }
}

.tools-menu-btn {
  background: linear-gradient(135deg, #77081e, #a00e2e);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(119, 8, 30, 0.3);
  animation: pulse-glow 1.5s ease-in-out 3;
}

.tools-menu-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(119, 8, 30, 0.4);
  animation: none;
}

.tools-menu-btn:active {
  transform: translateY(0);
}

.tools-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #ffffff;
  border: 1px solid #e5e9f3;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(16, 19, 24, 0.18);
  min-width: 250px;
  padding: 6px 0;
  animation: fadeUp 0.2s ease;
}

.tools-dropdown.active {
  display: block;
}

.tools-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #101318;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.12s;
}

.tools-dropdown-item:hover {
  background: #f0f4ff;
  text-decoration: none;
}

.td-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.td-pdf { background: rgba(34,211,238,.12); color: #06b6d4; }
.td-image { background: rgba(245,158,11,.12); color: #d97706; }
.td-finance { background: rgba(34,197,94,.12); color: #16a34a; }
.td-productivity { background: rgba(99,102,241,.12); color: #6366f1; }
.td-text { background: rgba(244,114,182,.12); color: #ec4899; }
.td-seo { background: rgba(168,85,247,.12); color: #a855f7; }

.tools-dropdown-footer {
  border-top: 1px solid #e5e9f3;
  padding: 8px 16px;
  text-align: center;
}

.tools-dropdown-footer a {
  color: #1a4ba3;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

.tools-dropdown-footer a:hover {
  text-decoration: underline;
}

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

@media (max-width: 720px) {
  .tools-dropdown {
    left: auto;
    right: 0;
    transform: none;
    min-width: 220px;
  }
}

/* ===== SEO Content Section ===== */
.seo-content {
  width: 100%;
  max-width: 1200px;
  margin: 2rem auto 0;
  padding: 0 1rem 2rem;
}

.seo-inner {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(148,163,184,0.15);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  color: rgba(209,213,219,0.9);
}

.seo-inner h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.75rem;
}

.seo-inner h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f0f4ff;
  margin: 1.5rem 0 0.75rem;
}

.seo-inner h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 0.3rem;
}

.seo-inner p {
  font-size: 0.9rem;
  line-height: 1.7;
  color: rgba(209,213,219,0.8);
  margin-bottom: 0.5rem;
}

.seo-inner strong {
  color: #f0f4ff;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 0.5rem 0;
}

.seo-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(148,163,184,0.1);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  transition: background 0.2s;
}

.seo-card:hover {
  background: rgba(255,255,255,0.08);
}

.seo-card p {
  font-size: 0.82rem;
  margin: 0;
}

.seo-steps {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.seo-steps li {
  font-size: 0.9rem;
  line-height: 1.7;
  color: rgba(209,213,219,0.8);
  margin-bottom: 0.3rem;
}

@media (max-width: 768px) {
  .seo-inner { padding: 1.25rem 1rem; }
  .seo-inner h2 { font-size: 1.25rem; }
  .seo-grid { grid-template-columns: 1fr; }
  .seo-content { padding: 0 0.75rem 1.5rem; }
}

footer a:hover {
  text-decoration: underline;
}

/* ===== AdSense Ad Containers ===== */
.ad-container {
  width: 100%;
  max-width: 1200px;
  margin: 0.5rem auto;
  padding: 0 1rem;
  min-height: 90px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  overflow: hidden;
}

.ad-container ins {
  width: 100%;
}

.ad-inarticle {
  margin: 1.5rem 0;
  padding: 0.5rem 0;
  min-height: 120px;
  background: transparent;
  border-top: 1px solid rgba(148,163,184,0.1);
  border-bottom: 1px solid rgba(148,163,184,0.1);
  border-radius: 0;
}

@media (min-width: 768px) {
  .ad-container {
    min-height: 120px;
  }
}

/* ===== FAQ Section (Compact) ===== */
.faq-section {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 0.5rem;
}

.faq-inner {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(148,163,184,0.1);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
}

.faq-inner h2 {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 1rem;
  text-align: center;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.faq-item {
  border: 1px solid rgba(148,163,184,0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
  transition: background 0.15s;
}

.faq-item:hover {
  background: rgba(255,255,255,0.04);
}

.faq-item summary {
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e7eb;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  user-select: none;
}

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

.faq-item summary::before {
  content: "▸";
  font-size: 0.75rem;
  color: rgba(148,163,184,0.5);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.faq-item[open] summary::before {
  transform: rotate(90deg);
}

.faq-item[open] summary {
  border-bottom: 1px solid rgba(148,163,184,0.06);
}

.faq-item p {
  padding: 0 14px 10px;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: rgba(209,213,219,0.75);
}

@media (max-width: 768px) {
  .faq-inner {
    padding: 1rem 0.875rem;
  }
  .faq-inner h2 {
    font-size: 1.05rem;
  }
  .faq-item summary {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
  .faq-item p {
    font-size: 0.75rem;
    padding: 0 12px 8px;
  }
  .faq-section {
    padding: 0 0.75rem 1.5rem;
  }
}
