/* ==========================================================================
   SpecView Clean Studio UI (Inspired by PhoneSized, DisplayWars & Smallpdf)
   - Zero nested box-in-box clutter
   - Direct visual hierarchy, tabular numerals, crisp studio canvas
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

:root {
  --bg-page: #f8f8f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f3f3f5;
  --bg-canvas: #ffffff;
  --border: #e4e4e7;
  --border-strong: #d1d1d6;
  --text-main: #18181b;
  --text-sub: #52525b;
  --text-muted: #5c5c66;
  --primary: #1a56db;
  --primary-hover: #1545b5;
  --primary-soft: #eef2ff;
  --device-a: #1a56db;
  --device-a-fill: rgba(26, 86, 219, 0.11);
  --device-b: #ea580c;
  --device-b-fill: rgba(234, 88, 12, 0.12);
  --device-c: #7c3aed;
  --device-c-fill: rgba(124, 58, 237, 0.11);
  --ref-color: #047857;
  --ref-fill: rgba(4, 120, 87, 0.12);
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --success: #047857;
  --success-soft: #ecfdf5;
  --shadow-sm: none;
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius-xl: 8px;
  --radius-lg: 6px;
  --radius-md: 5px;
  --radius-sm: 4px;
}

[data-theme="dark"] {
  --bg-page: #111113;
  --bg-surface: #18181b;
  --bg-subtle: #222226;
  --bg-canvas: #141417;
  --border: #2c2c32;
  --border-strong: #3d3d45;
  --text-main: #f4f4f5;
  --text-sub: #d4d4d8;
  --text-muted: #a1a1aa;
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --device-a: #60a5fa;
  --device-a-fill: rgba(96, 165, 250, 0.16);
  --device-b: #fb923c;
  --device-b-fill: rgba(251, 146, 60, 0.16);
  --device-c: #a78bfa;
  --device-c-fill: rgba(167, 139, 250, 0.16);
  --ref-color: #34d399;
  --ref-fill: rgba(52, 211, 153, 0.14);
  --danger-soft: rgba(239, 68, 68, 0.14);
  --success-soft: rgba(16, 185, 129, 0.14);
  --shadow-sm: none;
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3);
}

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

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ==========================================================================
   Top Navigation Bar
   ========================================================================== */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.header-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-logo {
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1.5px solid var(--text-main);
  background: transparent;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 0 12px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  border-radius: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  transition: color 0.12s ease;
}

.nav-link:hover {
  color: var(--text-main);
  background: transparent;
}

.nav-link.active {
  color: var(--text-main);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sub);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

@media (max-width: 680px) {
  .header-container {
    height: auto;
    padding: 10px 14px 0;
    flex-wrap: wrap;
    gap: 8px;
  }
  .main-nav {
    order: 3;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 1px solid var(--border);
    padding: 2px 0 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .nav-link {
    flex-shrink: 0;
    height: auto;
    border-radius: 0;
    padding: 9px 10px;
    font-size: 0.84rem;
    white-space: nowrap;
  }
  .nav-link.active {
    background: transparent;
    color: var(--text-main);
    box-shadow: inset 0 -2px 0 var(--text-main);
  }
  .theme-toggle {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
}

.studio-title-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 10px;
}

.studio-h1 {
  font-size: 1.36rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.studio-sub {
  font-size: 0.88rem;
  color: var(--text-sub);
}

@media (max-width: 680px) {
  .studio-h1 { font-size: 1.22rem; }
  .studio-sub { font-size: 0.82rem; }
  .nav-link { padding: 10px 10px; font-size: 0.85rem; }
}

/* ==========================================================================
   Main Page Container
   ========================================================================== */
.page-wrap {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 60px;
  flex: 1;
}

@media (max-width: 680px) {
  .page-wrap { padding: 14px 12px 44px; }
}

.page-intro {
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.page-desc {
  font-size: 0.86rem;
  color: var(--text-sub);
}

/* Quick Preset Bar */
.quick-match-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 2px;
}

.preset-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 2px;
}

.chip-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-sub);
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.chip-btn:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

/* ==========================================================================
   Unified Workbench Card (PhoneSized / DisplayWars Integrated Studio)
   ========================================================================== */
.studio-workbench {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: none;
  overflow: hidden;
  margin-bottom: 24px;
}

/* Mobile Device Tabs */
.mobile-device-tabs {
  display: none;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

@media (max-width: 820px) {
  .mobile-device-tabs { display: grid; }
  .mobile-device-tabs.three-tabs { grid-template-columns: 1fr 1fr 1fr; }
}

.mob-tab-btn {
  padding: 10px 8px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-sub);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.mob-tab-btn > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mob-tab-btn.active-a { border-bottom-color: var(--device-a); color: var(--device-a); background: var(--bg-surface); }
.mob-tab-btn.active-b { border-bottom-color: var(--device-b); color: var(--device-b); background: var(--bg-surface); }
.mob-tab-btn.active-c { border-bottom-color: var(--device-c); color: var(--device-c); background: var(--bg-surface); }

/* Top Control Strip inside Workbench */
.compare-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  align-items: center;
}

.compare-controls.three-cols {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
}
.compare-controls.three-cols .swap-circle { display: none; }

@media (max-width: 820px) {
  .compare-controls,
  .compare-controls.three-cols {
    grid-template-columns: minmax(0, 1fr);
  }
  .compare-controls .swap-circle { display: none; }
  .ctrl-card.mob-hidden { display: none !important; }
}

.ctrl-card {
  padding: 14px 18px;
  min-width: 0;
  width: 100%;
}

.ctrl-card.card-b,
.ctrl-card.card-c {
  border-left: 1px solid var(--border);
}

@media (max-width: 820px) {
  .ctrl-card.card-b,
  .ctrl-card.card-c { border-left: none; }
}

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

.ctrl-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  font-size: 0.9rem;
  font-weight: 800;
  min-width: 0;
}

.color-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  flex-shrink: 0;
}

.color-a { background: var(--device-a); }
.color-b { background: var(--device-b); }
.color-c { background: var(--device-c); }

.live-dim-readout {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-sub);
}

.ctrl-inline-inputs {
  display: grid;
  grid-template-columns: 1.4fr 0.75fr 1fr;
  gap: 8px;
  align-items: end;
}

@media (max-width: 520px) {
  .ctrl-inline-inputs {
    grid-template-columns: 1fr 1fr;
  }
  .ctrl-inline-inputs > .field:first-child {
    grid-column: 1 / -1;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  outline: none;
  height: 35px;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
}

.custom-inline-pair {
  display: none;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}
.custom-inline-pair.visible { display: grid; }

.swap-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  transition: all 0.15s;
}

.swap-circle:hover {
  color: var(--text-main);
  border-color: var(--text-main);
}

/* Direct 1-Line Human Headline Summary Banner */
.headline-diff-banner {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 11px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.88rem;
}

/* Canvas Toolbar */
.stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.segmented-group {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  padding: 5px 11px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}

.seg-btn:hover { color: var(--text-main); }

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.toolbar-right-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.compact-select {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  height: 30px;
}

.btn-subtle {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-sub);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn-subtle:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-subtle.active {
  background: var(--text-main);
  color: var(--bg-surface);
  border-color: var(--text-main);
}

.btn-primary {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--primary-hover); }

.calibration-drawer {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  display: none;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.82rem;
}
.calibration-drawer.open { display: flex; }

/* Studio Drawing Canvas */
.canvas-box {
  width: 100%;
  height: 480px;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
  user-select: none;
  touch-action: pan-y;
}

@media (max-width: 680px) {
  .canvas-box { height: 340px; }
}

#comparisonSvg {
  width: 100%;
  height: 100%;
  display: block;
}

.draggable-screen { cursor: grab; }
.draggable-screen:active { cursor: grabbing; }

/* Bottom Visual Area & Dimension Bar inside Workbench (DisplayWars Style) */
.visual-diff-strip {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 760px) {
  .visual-diff-strip {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

.diff-stat-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.diff-stat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--text-sub);
  font-weight: 600;
}

.diff-stat-head strong {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text-main);
}

.dual-bar-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dual-bar-line {
  display: grid;
  grid-template-columns: 48px 1fr 76px;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-sub);
}

.bar-track-flat {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill-a { height: 100%; background: var(--device-a); border-radius: 4px; }
.bar-fill-b { height: 100%; background: var(--device-b); border-radius: 4px; }
.bar-fill-c { height: 100%; background: var(--device-c); border-radius: 4px; }

/* ==========================================================================
   Clean Section Cards & Spec Tables
   ========================================================================== */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

@media (max-width: 680px) {
  .section-card { padding: 16px 14px; }
}

.section-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.section-header-row .section-title { margin-bottom: 0; }

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.clean-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.clean-table th,
.clean-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.86rem;
}

.clean-table thead th {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
}

.clean-table tbody th {
  color: var(--text-sub);
  font-weight: 600;
  width: 26%;
}

.clean-table td.col-a { color: var(--device-a); font-weight: 700; }
.clean-table td.col-b { color: var(--device-b); font-weight: 700; }
.clean-table td.col-c { color: var(--device-c); font-weight: 700; }

.popular-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.popular-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-sub);
  transition: all 0.12s;
}

.popular-link:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

ins.adsbygoogle {
  display: block;
  min-height: 90px;
}

/* ==========================================================================
   PDF Tool Navigation & Thumbnails (Smallpdf / iLovePDF Clean Workspace)
   ========================================================================== */
.pdf-tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tool-tile-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.12s ease;
  color: var(--text-sub);
  font-size: 0.84rem;
  font-weight: 600;
}

.tool-tile-btn:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

.tool-tile-btn.active {
  background: var(--text-main);
  border-color: var(--text-main);
  color: var(--bg-surface);
  font-weight: 700;
}

.tool-tile-icon {
  font-size: 0.92rem;
  line-height: 1;
}

.tool-tile-name {
  white-space: nowrap;
}

.tool-tile-sub {
  display: none;
}

.thumb-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.thumb-item {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.thumb-item:hover { border-color: var(--primary); }
.thumb-item.selected { border-color: var(--primary); background: var(--primary-soft); }
.thumb-item.selected-danger { border-color: var(--danger); background: var(--danger-soft); }

.thumb-item img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: block;
  margin-bottom: 5px;
}

.thumb-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.pdf-progress-wrap {
  display: none;
  margin: 14px 0;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.pdf-progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg-surface);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.pdf-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.18s ease;
}

.rot-card-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
}

.rot-mini-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
}

.rot-mini-btn:hover {
  border-color: var(--text-main);
}

.sig-pad-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#sigDrawCanvas {
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  cursor: crosshair;
  touch-action: none;
  max-width: 100%;
}

.extracted-text-area {
  width: 100%;
  min-height: 260px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 0.88rem;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

.field-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 640px) {
  .field-row-2 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Full 104-Key Visual Keyboard Map & Hardware Diagnostics
   ========================================================================== */
.visual-kb-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.full-kb-deck {
  min-width: 920px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: grid;
  grid-template-columns: 3.1fr 0.68fr 0.92fr;
  gap: 12px;
  user-select: none;
}

.kb-section { display: flex; flex-direction: column; gap: 5px; }
.kb-row { display: flex; gap: 4px; }

.kb-key {
  height: 36px;
  min-width: 28px;
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  text-align: center;
}

.kb-key.w-15 { flex: 1.5; }
.kb-key.w-18 { flex: 1.8; }
.kb-key.w-22 { flex: 2.2; }
.kb-key.w-space { flex: 6.2; }
.kb-key.empty { visibility: hidden; border: none; background: transparent; }
.kb-key.tested { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.kb-key.active { background: var(--primary); border-color: var(--primary); color: #ffffff; }
.kb-key.fault { background: var(--danger); border-color: var(--danger); color: #ffffff; }

/* FAQ & Guide Articles */
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface); }
.faq-item summary {
  padding: 13px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 1.1rem; color: var(--text-muted); }
.faq-item[open] summary::after { content: '−'; color: var(--text-main); }
.faq-body { padding: 0 16px 14px; font-size: 0.84rem; color: var(--text-sub); line-height: 1.65; }
.faq-body ul { margin-left: 18px; display: flex; flex-direction: column; gap: 4px; }

.guide-article { display: flex; flex-direction: column; gap: 14px; font-size: 0.9rem; color: var(--text-sub); line-height: 1.75; }
.guide-article h2, .guide-article h3 { font-size: 1.02rem; font-weight: 800; color: var(--text-main); margin-top: 8px; }
.guide-article ul, .guide-article ol { margin-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .guide-grid { grid-template-columns: 1fr; } }

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast-msg {
  background: var(--text-main);
  color: var(--bg-surface);
  padding: 11px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.84rem;
  font-weight: 600;
}
.toast-msg.error { background: var(--danger); color: #fff; }
.toast-msg.success { background: var(--success); color: #fff; }

.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--text-sub); font-weight: 600; }
.footer-links a:hover { color: var(--text-main); }


/* ==========================================================================
   v5.0 SaaS Studio Refinements, Table Studio & AdSense CLS-Zero Slot
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;600;700&display=swap');

::selection {
  background: var(--primary-soft);
  color: var(--text-main);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.mono-num, .live-dim-readout {
  font-family: 'JetBrains Mono', 'Pretendard', monospace;
  letter-spacing: -0.02em;
}

.site-header {
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.ad-slot-reserve {
  width: 100%;
  min-height: 90px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 18px 0;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
}

.summary-tip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 760px) {
  .summary-tip-grid { grid-template-columns: 1fr; }
}
.summary-tip-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.summary-tip-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.summary-tip-card h3 {
  font-size: 0.94rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text-main);
}
.summary-tip-card p {
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.55;
}

/* ==========================================================================
   Final Mobile Overrides (<= 680px) - Placed last so base rules never win
   ========================================================================== */
@media (max-width: 680px) {
  .quick-match-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    padding-right: 18px;
    -webkit-mask-image: linear-gradient(to right, #000 92%, transparent 100%);
    mask-image: linear-gradient(to right, #000 92%, transparent 100%);
  }

  .quick-match-bar::-webkit-scrollbar {
    display: none;
  }

  .quick-match-bar .chip-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .segmented-group {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .seg-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .popular-links-grid {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(2, auto);
    grid-auto-columns: max-content;
    grid-template-columns: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 6px;
    padding-right: 18px;
    -webkit-mask-image: linear-gradient(to right, #000 92%, transparent 100%);
    mask-image: linear-gradient(to right, #000 92%, transparent 100%);
  }

  .popular-links-grid::-webkit-scrollbar {
    display: none;
  }

  .popular-link {
    padding: 9px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
    gap: 10px;
  }

  .popular-link span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .popular-link span:last-child {
    flex-shrink: 0;
  }

  .section-card {
    padding: 16px 14px;
  }

  input, select, textarea {
    font-size: 16px;
  }

  .pdf-tool-grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .pdf-tool-grid::-webkit-scrollbar {
    display: none;
  }

  .tool-tile-btn {
    flex-shrink: 0;
    padding: 7px 11px;
    font-size: 0.8rem;
  }
}
