/* ============================================================
   PencilArt — clean, minimal layout
   Light "paper" theme. No frameworks, no external assets.
   ============================================================ */

:root {
  --bg: #f3f0e9;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #26221b;
  --muted: #8b8477;
  --faint: #b6afa1;
  --line: #e8e2d5;
  --line-strong: #d8d0bf;
  --accent: #c05621;
  --accent-deep: #9a3412;
  --accent-soft: #fdf0e3;
  --ok: #2f855a;
  --shadow-sm: 0 1px 2px rgba(74, 58, 34, .05), 0 6px 18px rgba(74, 58, 34, .07);
  --shadow-lg: 0 2px 4px rgba(74, 58, 34, .06), 0 18px 44px rgba(74, 58, 34, .14);
  --radius: 18px;
  --radius-sm: 11px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(192, 86, 33, .06), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(120, 80, 40, .05), transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(192, 86, 33, .22); }

/* ============ TOP BAR ============ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 4px 14px rgba(192, 86, 33, .35);
  flex: none;
}
.logo svg { width: 21px; height: 21px; }

.brand-text h1 { font-size: 17px; font-weight: 800; letter-spacing: .2px; line-height: 1.1; }
.brand-text p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--ok);
  background: rgba(47, 133, 90, .08);
  border: 1px solid rgba(47, 133, 90, .28);
  padding: 6px 13px;
  border-radius: 99px;
  white-space: nowrap;
}

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  display: inline-block;
  flex: none;
}
.dot.busy { background: var(--accent); animation: pulse 1s ease infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ============ LAYOUT ============ */

.wrap {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 26px 22px 34px;
  display: flex;
  flex-direction: column;
}

/* ============ DROPZONE / EMPTY STATE ============ */

.dropzone {
  flex: 1;
  min-height: 420px;
  display: grid; place-items: center;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease, transform .2s ease;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--surface-2);
}
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 3px rgba(192, 86, 33, .18), var(--shadow-lg);
}

.dz-inner { padding: 30px; max-width: 480px; }

.dz-icon {
  width: 82px; height: 82px;
  margin: 0 auto 20px;
  display: grid; place-items: center;
  color: var(--accent);
  border-radius: 24px;
  background: var(--accent-soft);
  border: 1px solid rgba(192, 86, 33, .22);
  box-shadow: var(--shadow-sm);
}
.dz-icon svg { width: 40px; height: 40px; }

.dropzone h2 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.dropzone p { font-size: 14px; color: var(--muted); line-height: 1.65; margin-bottom: 24px; }

.kbd-hint {
  display: block;
  margin-top: 16px;
  font-size: 12px;
  color: var(--faint);
}
kbd {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--muted);
}

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 13.5px; font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--faint); }
.btn:active { transform: translateY(0) scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border: none;
  color: #fff;
  box-shadow: 0 4px 16px rgba(192, 86, 33, .32);
}
.btn-primary:hover { box-shadow: 0 6px 22px rgba(192, 86, 33, .45); filter: brightness(1.06); }
.btn-ghost { background: transparent; }

/* ============ WORKING VIEW ============ */

.stage { display: flex; flex-direction: column; gap: 18px; animation: fadeUp .35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.filename {
  font-size: 13px;
  color: var(--muted);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Panels */

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel figcaption { padding: 13px 16px 0; }

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 12px;
}
.chip-accent {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: rgba(192, 86, 33, .25);
}

.frame {
  position: relative;
  margin: 14px;
  border-radius: var(--radius-sm);
  background:
    repeating-conic-gradient(rgba(60, 45, 20, .045) 0% 25%, transparent 0% 50%) 0 0 / 22px 22px,
    var(--surface-2);
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.frame canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

/* Busy overlay */

.busy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(3px);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-deep);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.busy.on { opacity: 1; pointer-events: auto; }

.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(192, 86, 33, .18);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Status line */

.statusline {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
}

/* ============ FOOTER ============ */

.foot {
  text-align: center;
  font-size: 12px;
  color: var(--faint);
  padding: 14px 20px 26px;
}

/* ============ UTIL ============ */

.hidden { display: none !important; }

/* ============ RESPONSIVE ============ */

@media (max-width: 760px) {
  .panels { grid-template-columns: 1fr; }
  .dropzone { min-height: 320px; }
  .wrap { padding: 18px 14px 26px; }
  .toolbar { justify-content: center; text-align: center; }
  .badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
