:root {
  --bg: #0e1217;
  --fg: #e7ecf3;
  --muted: #9aa7b2;
  --card: #141a22;
  --border: #263041;
  --brand: #5b9cff;
  --brand-2: #6ae5d8;
  --ok: #3ccf91;
  --warn: #ffb86b;
}

:root.light {
  --bg: #ffffff;
  --fg: #0f1720;
  --muted: #4a5662;
  --card: #f5f7fb;
  --border: #e3e7ee;
  --brand: #2b6ff5;
  --brand-2: #16c8b8;
  --ok: #12b886;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.6;
}

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); z-index: 50;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--fg); }
.logo { width: 36px; height: 36px; object-fit: contain; }
.logo.sm { width: 28px; height: 28px; }
.brand-name { font-weight: 700; letter-spacing: .2px; }

.nav { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--fg); opacity: .85; padding: .4rem .6rem; border-radius: 8px; }
.nav a:hover, .nav a.active { background: var(--card); opacity: 1; }

.theme-toggle { border: 1px solid var(--border); background: var(--card); color: var(--fg); padding: .4rem .6rem; border-radius: 10px; cursor: pointer; }

/* Hero */
.hero { padding: 3.5rem 1rem 2rem; background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 20%, transparent), transparent); }
.hero-inner { max-width: 1100px; margin: 0 auto; text-align: center; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); margin: 0 0 .5rem; }
.hero p { color: var(--muted); margin: 0 auto 1.25rem; max-width: 800px; }

.btn { display: inline-block; padding: .7rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--fg); text-decoration: none; cursor: pointer; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #0b1220; font-weight: 700; }
.btn.success { background: linear-gradient(135deg, var(--ok), #9be7c1); border-color: transparent; color: #072014; font-weight: 700; }

/* Sections */
main section { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem; }
section h2 { margin: 0 0 1rem; }

/* Tool grid */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.tool-card { display: block; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; color: var(--fg); text-decoration: none; }
.tool-card h3 { margin: 0 0 .4rem; }
.tool-card p { margin: 0 0 .6rem; color: var(--muted); }
.tool-card:hover { outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent); }

/* Tool boxes */
.tool-box { display: grid; grid-template-columns: 360px 1fr; gap: 1rem; }
@media (max-width: 900px) { .tool-box { grid-template-columns: 1fr; } }
.controls { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; }
.file-row { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.file-label input { display: none; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid.two label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .25rem; }
.grid.two input, .grid.two select, textarea, input[type="text"], input[type="email"] { width: 100%; padding: .6rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); }
.action-row { display: flex; gap: .6rem; margin-top: .6rem; }
.hint { color: var(--muted); font-size: .9rem; }

/* Preview */
.preview { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; min-height: 420px; }
.preview-inner { position: relative; width: 100%; overflow: auto; border-radius: 8px; background: repeating-conic-gradient(#0000 0 90deg, color-mix(in srgb, var(--border) 30%, transparent) 0 180deg) 50% / 20px 20px; }
#areaCanvas, #singleCanvas { display: block; max-width: 100%; height: auto; margin: 0 auto; }

/* Overlay */
.crop-overlay {
  position: absolute; border: 2px dashed color-mix(in srgb, var(--brand) 60%, white 10%); pointer-events: auto; touch-action: none;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}
.crop-overlay .handle { width: 12px; height: 12px; background: var(--brand); border: 2px solid white; border-radius: 50%; position: absolute; transform: translate(-50%, -50%); }
.handle.tl { top: 0%; left: 0%; }
.handle.tr { top: 0%; left: 100%; }
.handle.bl { top: 100%; left: 0%; }
.handle.br { top: 100%; left: 100%; }

/* Merge list */
.file-list { list-style: none; padding: 0; margin: .6rem 0 0; border: 1px dashed var(--border); border-radius: 10px; }
.file-list li { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; border-bottom: 1px solid var(--border); gap: .5rem; }
.file-list li:last-child { border-bottom: 0; }
.file-list .drag { cursor: grab; user-select: none; }
.file-list .remove { background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--fg); padding: .25rem .5rem; cursor: pointer; }

/* FAQ */
.accordion { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
.acc-btn { width: 100%; text-align: left; background: var(--card); color: var(--fg); padding: 1rem; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 1rem; }
.acc-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--brand) 12%, var(--card)); }
.acc-panel { display: none; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.acc-panel.open { display: block; }

/* Page + Footer */
.page { max-width: 900px; margin: 0 auto; padding: 2rem 1rem; }
.small { font-size: .9rem; color: var(--muted); }
.site-footer { border-top: 1px solid var(--border); padding: 1rem; }
.footer-grid { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.footer-nav { display: flex; gap: .8rem; flex-wrap: wrap; }
.footer-nav a { color: var(--fg); text-decoration: none; opacity: .8; }
.footer-nav a:hover { opacity: 1; }
