/* ============================================================
   DewDew Tools — shared UI shell
   Phone-first: designed at 390px, then scaled up.
   Tap targets: buttons >= 52px, chips/rows >= 44px.
   No horizontal overflow at 320px–1400px+.
   ============================================================ */

:root {
  --green: #0f766e;
  --green-dark: #134e4a;
  --green-soft: #e6f2f0;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f5f8f7;
  --card: #ffffff;
  --line: #e3e9ef;
  --amber-bg: #fef3c7;
  --amber-ink: #92400e;
  --red-bg: #fee2e2;
  --red-ink: #991b1b;
  --radius: 18px;
  --shadow: 0 10px 26px rgba(15, 23, 42, .07);
  --shadow-green: 0 10px 24px rgba(15, 118, 110, .24);
}

* { box-sizing: border-box; }

/* ★ [hidden] 은 항상 이긴다 — .tw-progress/.tw-notice 등이 display:flex 를 갖고 있어
   hidden 속성만으로는 숨겨지지 않던 실제 버그(스피너가 로드 직후 항상 보임)를 막는다. */
[hidden] { display: none !important; }

html, body { max-width: 100%; overflow-x: hidden; }

body.tw-body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; }

/* ---------- top bar ---------- */

.tw-top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.tw-top-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tw-brand { display: inline-flex; align-items: center; min-height: 44px; flex: 0 0 auto; }
.tw-brand img { height: 26px; width: auto; display: block; }

.tw-top-nav { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }

.tw-top-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--green-dark);
  background: var(--green-soft);
  text-decoration: none;
  white-space: nowrap;
}
.tw-top-link-alt { background: transparent; color: var(--muted); }

/* ---------- page column ---------- */

.tw-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 44px;
}
.tw-wrap-tool { padding-top: 10px; }

/* ---------- hero + search (index) ---------- */

.tw-hero { padding: 10px 2px 4px; }

.tw-hero-title {
  margin: 0 0 8px;
  font-size: 27px;
  line-height: 1.18;
  letter-spacing: -.02em;
}

.tw-hero-sub { margin: 0 0 16px; color: var(--muted); font-size: 15px; }

.tw-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 15px;
  padding: 0 14px;
  box-shadow: var(--shadow);
}
.tw-search-icon { font-size: 16px; }

.tw-search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  min-height: 52px;
  color: var(--ink);
}

/* ---------- category chips ---------- */

.tw-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 2px 4px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}
.tw-chips::-webkit-scrollbar { display: none; }

.tw-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.tw-chip.is-on { background: var(--green); border-color: var(--green); color: #fff; }

.tw-count { color: var(--muted); font-size: 13px; margin: 10px 2px 14px; }
.tw-count strong { color: var(--green-dark); }

/* ---------- tool cards ---------- */

.tw-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tw-grid-tight { gap: 10px; }

.tw-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: var(--ink);
  min-height: 64px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .03);
}
.tw-card:active { transform: scale(.995); }
.tw-card.is-soon { opacity: .78; }

.tw-card-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--green-soft);
  border-radius: 13px;
}

.tw-card-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tw-card-name { font-weight: 800; font-size: 15.5px; }
.tw-card-desc {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tw-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
}
.tw-badge-live { background: #dcfce7; color: #166534; }
.tw-badge-soon { background: var(--amber-bg); color: var(--amber-ink); }

/* ---------- empty state ---------- */

.tw-empty {
  background: var(--card);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px 18px;
  text-align: center;
}
.tw-empty-icon { font-size: 30px; }
.tw-empty-title { font-weight: 800; margin: 10px 0 4px; }
.tw-empty-sub { color: var(--muted); font-size: 13.5px; margin: 0; }
.tw-empty a { color: var(--green); font-weight: 700; display: inline-flex; align-items: center; min-height: 44px; }

/* 인라인 링크도 손가락으로 누를 수 있게 (>=44px) */
.tw-sect a, .tw-privacy a, .tw-tool-card a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* ---------- tool page ---------- */

.tw-crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 8px 2px 2px;
  flex-wrap: wrap;
}
.tw-crumbs a {
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.tw-crumb-here { color: var(--ink); font-weight: 700; }

.tw-tool-head { padding: 8px 2px 14px; }
.tw-tool-title { margin: 0 0 8px; font-size: 25px; line-height: 1.2; letter-spacing: -.02em; }
.tw-tool-intro { margin: 0 0 10px; color: #334155; font-size: 15px; }
.tw-trust { margin: 0; font-size: 12.5px; color: var(--green-dark); font-weight: 700; }

.tw-tool-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow);
}

/* dropzone */

.tw-drop {
  position: relative;
  border: 2px dashed #c7d2dc;
  border-radius: 18px;
  background: #fbfdfc;
  padding: 26px 16px 20px;
  text-align: center;
  cursor: pointer;
}
.tw-drop.is-drag { border-color: var(--green); background: #f0fdfa; }
.tw-drop.has-file { border-style: solid; border-color: var(--green); }

.tw-drop-icon { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.tw-drop-title { margin: 0 0 4px; font-weight: 800; font-size: 16px; }
.tw-drop-hint { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }

.tw-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.tw-pick { pointer-events: none; } /* input 이 클릭을 받는다 */

/* file list */

.tw-filelist { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

.tw-file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  min-height: 44px;
}
.tw-file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.tw-file-size { color: var(--muted); flex: 0 0 auto; }
.tw-file-x {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 15px;
  cursor: pointer;
}
.tw-file-move {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

/* options */

.tw-options { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }

.tw-opt { display: flex; flex-direction: column; gap: 6px; }
.tw-opt-label { font-size: 13px; font-weight: 800; color: #334155; }
.tw-opt-out { color: var(--green); font-weight: 800; }

.tw-input {
  width: 100%;
  min-height: 50px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fff;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}
.tw-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 118, 110, .14); }

.tw-range { width: 100%; height: 44px; accent-color: var(--green); }

/* buttons */

.tw-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 15px;
  font-size: 16.5px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  text-align: center;
}

.tw-btn-primary { background: var(--green); color: #fff; box-shadow: var(--shadow-green); }
.tw-btn-primary:disabled { background: #b6c8c5; box-shadow: none; cursor: not-allowed; }
.tw-btn-ghost { background: #fff; color: var(--green-dark); border: 1.5px solid var(--line); margin-top: 10px; }

.tw-run { margin-top: 16px; }

/* progress (결과가 있는 동안에는 이전 결과를 가리지 않는다) */

.tw-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  color: var(--green-dark);
  font-weight: 700;
  font-size: 14px;
  min-height: 44px;
}

.tw-tool-card.is-updating .tw-result { opacity: .55; }

/* 도움말 톤 안내 (빨간 에러 아님) */

.tw-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 14px;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 14px;
  padding: 12px 14px;
}
.tw-notice-icon { font-size: 18px; line-height: 1.3; }
.tw-notice-text { margin: 0; color: #78350f; font-size: 13.5px; }

/* 힌트 (첫 행동 안내) */

.tw-hint {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  min-height: 44px;
}
.tw-hint-icon { font-size: 15px; }

/* 접힌 고급 옵션 */

.tw-more {
  margin-top: 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
  overflow: hidden;
}
.tw-more > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 16px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 13.5px;
  color: #334155;
}
.tw-more > summary::-webkit-details-marker { display: none; }
.tw-more > summary::after { content: "⌄"; color: var(--green); font-size: 17px; }
.tw-more[open] > summary::after { content: "⌃"; }
.tw-more .tw-options { padding: 0 14px 14px; }

.tw-spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(15, 118, 110, .25);
  border-top-color: var(--green);
  animation: tw-spin .8s linear infinite;
}
@keyframes tw-spin { to { transform: rotate(360deg); } }

/* result */

.tw-result { margin-top: 16px; border-top: 1.5px solid var(--line); padding-top: 16px; }

.tw-result-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.tw-result-check {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #dcfce7;
  color: #166534;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900;
}
.tw-result-title { margin: 0; font-weight: 800; font-size: 16.5px; }
.tw-result-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; word-break: break-word; }

.tw-download { margin-top: 4px; }

.tw-cross { margin-top: 16px; }
.tw-cross-title { margin: 0 0 8px; font-size: 13px; font-weight: 800; color: #334155; }
.tw-cross-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tw-cross-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--green-dark);
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
}

/* error → 도움말 톤으로 대체됨 (.tw-notice 사용) */

.tw-error { margin-top: 16px; border-top: 1.5px solid var(--line); padding-top: 16px; }
.tw-error-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.tw-error-icon {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--red-bg);
  color: var(--red-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900;
}
.tw-error-title { margin: 0; font-weight: 800; font-size: 16px; }
.tw-error-text { margin: 3px 0 0; color: #475569; font-size: 13.5px; }

/* coming-soon */

.tw-soon {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 22px;
  padding: 28px 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.tw-soon-icon { font-size: 34px; }
.tw-soon-title { margin: 10px 0 6px; font-size: 19px; }
.tw-soon-sub { color: #334155; font-size: 14px; margin: 0 0 10px; }
.tw-soon-note { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* ---------- ad slot (§11/§12) ---------- */

.tw-ad {
  margin: 20px 0 4px;
  background: #fffdf5;
  border: 1.5px solid #f1e5c8;
  border-radius: var(--radius);
  padding: 14px;
}
.tw-ad-label {
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #a16207;
}
.tw-ad-body { display: flex; gap: 12px; align-items: center; }
.tw-ad-icon { font-size: 26px; }
.tw-ad-title { margin: 0; font-weight: 800; font-size: 15px; }
.tw-ad-sub { margin: 2px 0 0; color: #6b7280; font-size: 12.5px; }
.tw-ad-cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid #f1e5c8;
  color: #a16207;
  font-weight: 800;
  font-size: 13.5px;
  text-decoration: none;
}

/* ---------- content sections ---------- */

.tw-sect { margin-top: 26px; }
.tw-sect-title { font-size: 17px; margin: 0 0 10px; }

.tw-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.tw-step { font-size: 14.5px; color: #334155; }

.tw-kv { display: flex; gap: 10px; font-size: 14px; margin: 0 0 10px; flex-wrap: wrap; }
.tw-kv-k { font-weight: 800; color: #334155; min-width: 72px; }
.tw-kv-v { color: #475569; }

.tw-uses { margin: 0; padding-left: 20px; color: #334155; font-size: 14.5px; display: flex; flex-direction: column; gap: 6px; }

.tw-faq {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  margin-bottom: 8px;
  overflow: hidden;
}
.tw-faq summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 800;
  font-size: 14.5px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tw-faq summary::-webkit-details-marker { display: none; }
.tw-faq summary::after { content: "+"; color: var(--green); font-size: 18px; font-weight: 900; }
.tw-faq[open] summary::after { content: "–"; }
.tw-faq p { margin: 0; padding: 0 16px 15px; color: #475569; font-size: 14px; }

.tw-privacy { margin-top: 20px; font-size: 13px; color: var(--muted); }

/* ---------- footer ---------- */

.tw-foot { border-top: 1px solid var(--line); background: #fff; margin-top: 34px; }
.tw-foot-inner { max-width: 560px; margin: 0 auto; padding: 18px 16px 30px; }

.tw-foot-links { display: flex; gap: 6px; flex-wrap: wrap; }
.tw-foot-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--green-dark);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
}
.tw-foot-note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

/* ---------- desktop scaling ---------- */

@media (min-width: 620px) {
  .tw-grid { grid-template-columns: 1fr 1fr; }
  .tw-hero-title { font-size: 32px; }
  .tw-wrap { max-width: 640px; }
}

@media (min-width: 1000px) {
  .tw-wrap { max-width: 860px; }
  .tw-grid { grid-template-columns: repeat(3, 1fr); }
  .tw-top-inner, .tw-foot-inner { max-width: 860px; }
}

/* §11: >=1400px — 좌/우 광고 레일 (하우스 광고) + 가운데 Tool */
.tw-shell { display: block; }
.tw-rail { display: none; }

@media (min-width: 1400px) {
  .tw-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 300px;
    gap: 26px;
    max-width: 1460px;
    margin: 0 auto;
    align-items: start;
  }
  .tw-rail { display: block; position: sticky; top: 74px; }
  .tw-shell .tw-wrap { margin: 0; max-width: none; }
}

/* 320px 안전 */
@media (max-width: 340px) {
  .tw-top-link { font-size: 12px; padding: 7px 9px; }
  .tw-hero-title { font-size: 23px; }
}

/* ============================================================
   Batch 2+ additions — 폼형 도구(파일 없음), 텍스트 결과, 인터랙티브 스테이지
   ============================================================ */

/* textarea 옵션 */
.tw-textarea {
  min-height: 110px;
  resize: vertical;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 12px 14px;
  width: 100%;
}

/* checkbox 옵션 */
.tw-opt-check { flex-direction: row; align-items: center; gap: 12px; }
.tw-opt-check input[type="checkbox"] {
  width: 26px; height: 26px; flex: 0 0 auto;
  accent-color: var(--green);
}
.tw-opt-check .tw-opt-label { font-size: 15px; }

/* 텍스트 결과 (계산기·OCR 요약·차이 비교 등) — 복사 대상 */
.tw-result-value {
  margin: 10px 0 0;
  padding: 14px 16px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  color: #0f3f3a;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}
.tw-result-value.is-long {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.55;
  max-height: 340px;
  overflow: auto;
}

/* 인터랙티브 스테이지 (크롭 캔버스·색상 픽커·미리보기 iframe) */
.tw-stage { margin-top: 14px; }
.tw-stage canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  touch-action: none;
  cursor: crosshair;
}
.tw-stage-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.tw-stage .tw-iframe { width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

/* 색상 픽커 스와치 */
.tw-swatch {
  display: inline-block;
  width: 54px; height: 54px;
  border-radius: 12px;
  border: 1px solid var(--line);
  vertical-align: middle;
  margin-right: 12px;
}

/* 녹음 도구 */
.tw-rec-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0 4px; }
.tw-rec-btn {
  width: 96px; height: 96px;
  min-width: 96px; min-height: 96px;
  border-radius: 50%;
  border: none;
  background: #dc2626;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(220, 38, 38, .35);
}
.tw-rec-btn.is-recording { background: var(--green); animation: tw-pulse 1.3s infinite; }
@keyframes tw-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, .45); }
  50% { box-shadow: 0 0 0 18px rgba(15, 118, 110, 0); }
}
.tw-rec-timer { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.tw-rec-note { margin: 0; font-size: 13px; color: var(--muted); text-align: center; font-weight: 600; }

/* 미리보기 (이메일 서명 등) */
.tw-preview-frame {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}