:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg2: #151a21;
  --card: #1a1f27;
  --border: #2a323c;
  --fg: #f4f1ea;
  --muted: #9aa3ad;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --danger: #ef4444;
  --success: #34d399;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(0,0,0,.4);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 8% -8%, #2dd4bf22, transparent),
    radial-gradient(800px 420px at 100% 0%, #14b8a618, transparent),
    var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

.app {
  max-width: 32rem;
  margin: 0 auto;
  min-height: 100%;
  padding: 0.75rem 1rem calc(1.5rem + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.35rem 0 0.15rem;
}
.brand { display: flex; align-items: center; gap: 0.65rem; min-width: 0; flex: 1 1 12rem; }
.brand > div { min-width: 0; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; border-radius: 0.7rem;
  background: linear-gradient(145deg, #1a1f27, #0e1116);
  border: 1px solid #2dd4bf44;
  display: grid; place-items: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px #2dd4bf33;
  flex-shrink: 0;
}
.brand h1 {
  margin: 0; font-size: 1.05rem; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand .tagline { margin: 0; font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lang-select {
  appearance: none;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  flex: 0 0 auto;
  max-width: 7.25rem;
  margin-left: auto;
}

.card {
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.card h2 { margin: 0 0 0.75rem; font-size: 0.95rem; font-weight: 700; }
.about { font-size: 0.82rem; color: var(--muted); }
.about p { margin: 0; }

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  gap: 0.5rem;
}
.list-head h2 { margin: 0; }

.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.55rem; }
.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: #12332f; color: var(--accent); border-color: #2dd4bf66; }

.custom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.custom-grid.fmt { grid-template-columns: 1fr; }

.btn {
  appearance: none; border: none; border-radius: 12px;
  padding: 0.75rem 1rem; font-weight: 700; font-size: 0.95rem;
  cursor: pointer; transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #04221e;
  box-shadow: 0 6px 16px #14b8a655;
}
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-danger {
  background: #7f1d1d55; color: #fecaca; border: 1px solid #ef444466;
}
.btn-sm { padding: 0.4rem 0.65rem; font-size: 0.78rem; border-radius: 8px; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

label {
  display: grid; gap: 0.35rem;
  font-size: 0.78rem; color: var(--muted); font-weight: 600;
}
input[type="text"], input[type="number"], input[type="url"], input[type="search"],
input[type="date"], input[type="tel"], input[type="email"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--fg);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  outline: none;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 2.6rem; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #2dd4bf33;
}
.grow { flex: 1; min-width: 0; }

.tool-row {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
}
.hint { margin: 0.45rem 0 0; font-size: 0.72rem; color: var(--muted); }

.footer {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  justify-content: center; font-size: 0.78rem; color: var(--muted);
  padding: 0.25rem 0 0.5rem;
}

.ad-slot {
  min-height: 100px; width: 100%;
  border: 1px dashed #3a4450; border-radius: 12px;
  background: #12161c88; overflow: hidden;
}
.ad-slot .adsbygoogle { display: block; min-height: 90px; width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + var(--safe-b));
  transform: translateX(-50%) translateY(120%);
  background: #04221e; color: #bbf7d0; border: 1px solid #16a34a88;
  padding: 0.65rem 1rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700;
  opacity: 0; transition: transform .25s ease, opacity .25s ease;
  z-index: 50; max-width: calc(100% - 2rem); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.drop {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  background: var(--bg2);
  text-align: center;
}
.drop.over { border-color: var(--accent); box-shadow: 0 0 0 3px #2dd4bf33; }
.drop p { margin: 0 0 0.5rem; font-size: 0.78rem; color: var(--muted); }

.preview-wrap {
  position: relative;
  background: #12161c;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px solid var(--border);
  touch-action: none;
  cursor: grab;
}
.preview-wrap.dragging { cursor: grabbing; }
.preview-wrap canvas {
  max-width: 100%;
  max-height: 280px;
  display: block;
  background: #0a0c10;
}
.preview-empty {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 1.4rem 0.8rem;
  text-align: center;
}

.meta-line {
  margin: 0.55rem 0 0;
  font-size: 0.88rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.meta-line.in-range { color: var(--success); }
.meta-line.out-range { color: var(--danger); }
.meta-sub { margin: 0.15rem 0 0; font-size: 0.72rem; color: var(--muted); }

.field-row {
  display: flex;
  gap: 0.4rem;
  align-items: end;
  margin-bottom: 0.55rem;
}
.field-row:last-child { margin-bottom: 0; }
.field-row label { flex: 1; min-width: 0; }
.field-row .btn { flex-shrink: 0; margin-bottom: 1px; }

@media (min-width: 520px) {
  .app { padding-top: 1.2rem; max-width: 36rem; }
}

.local-only {
  margin: 0 0 0.35rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: #111;
  background: #ffcc33;
  border: 1px solid #111;
  border-radius: 8px;
  overflow-wrap: anywhere;
  min-width: 0;
}
