:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-muted: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --radius: 12px;
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans KR", "Noto Sans Thai", "Noto Sans JP", "Hiragino Sans",
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

html[data-theme='dark'] {
  --bg-page: #0b1220;
  --bg-card: #111827;
  --bg-muted: #1f2937;
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;
  --border: #1f2937;
  --border-strong: #374151;
  --primary: #60a5fa;
  --primary-soft: #1e3a5f;
  --shadow: none;
}

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

html {
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--primary);
}

.site-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.main-nav::-webkit-scrollbar {
  display: none;
}

.main-nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.main-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-muted);
}

.main-nav a.active {
  color: var(--primary);
  background: var(--primary-soft);
}

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

.lang-wrap {
  position: relative;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  flex: none;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-mark svg {
  width: 16px;
  height: 16px;
}

.header-spacer {
  flex: 1;
}

.icon-btn,
.lang-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 8px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  position: relative;
  text-decoration: none;
}

.icon-btn:hover,
.lang-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

a.header-fav-link {
  color: var(--text-secondary);
}

a.header-fav-link:hover {
  color: #f59e0b;
  border-color: #f59e0b;
}

.icon-btn .fav-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  font-weight: 600;
}

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 168px;
  max-height: min(70vh, 420px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  z-index: 50;
  box-shadow: var(--shadow);
}

.lang-menu.open {
  display: block;
}

.lang-menu a {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.lang-menu a:hover,
.lang-menu a.active {
  background: var(--primary-soft);
  color: var(--primary);
}

#theme-btn .theme-icon-sun,
#theme-btn .theme-icon-moon {
  width: 18px;
  height: 18px;
  display: none;
}

html:not(.theme-is-dark) #theme-btn .theme-icon-moon,
html.theme-is-dark #theme-btn .theme-icon-sun {
  display: block;
}

.main {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px calc(48px + var(--safe-bottom));
}

.hero-tagline {
  color: var(--text-tertiary);
  font-size: 13px;
  margin: -8px 0 16px;
}

.cat-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin: -6px 0 12px;
}

.cat-block {
  margin-bottom: 28px;
}

.cat-block > h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
}

.hero-sub {
  color: var(--text-secondary);
  margin: 0 0 18px;
  max-width: 42rem;
}

.search-box {
  position: relative;
  max-width: 420px;
}

.search-box input {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 0 14px;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.search-box input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.section {
  margin-top: 36px;
}

.section h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.section-anchor,
.section-anchor > h2 {
  scroll-margin-top: calc(var(--header-h) + var(--safe-top) + 12px);
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 120px;
  overflow: hidden;
}

.tool-card:hover {
  border-color: var(--primary);
}

.tool-card-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  padding: 16px;
  padding-right: 42px;
  color: inherit;
  text-decoration: none;
  min-height: 120px;
}

.tool-card-link:hover {
  color: inherit;
}

.fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 8px;
  padding: 0;
  line-height: 0;
}

.fav-btn:hover {
  color: #f59e0b;
  background: var(--bg-muted);
}

.fav-btn.faved {
  color: #f59e0b;
}

.fav-btn.faved svg {
  fill: currentColor;
}

.fav-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}

.favorites-empty-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  padding: 20px 16px;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

.tool-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.tool-icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
  display: inline-flex;
}

.tool-icon svg {
  width: 22px;
  height: 22px;
}

.tool-card-desc {
  color: var(--text-secondary);
  font-size: 13px;
  flex: 1;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  width: fit-content;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text-secondary);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: 18px 20px calc(18px + var(--safe-bottom));
  color: var(--text-tertiary);
  font-size: 13px;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.footer-about {
  margin: 0 0 10px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 72ch;
}

.footer-note {
  margin: 0 0 12px;
}

.faq-section .faq-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.faq-item + .faq-item {
  margin-top: 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.faq-q {
  font-weight: 600;
  margin: 0 0 6px;
  display: flex;
  gap: 8px;
  color: var(--text-primary);
  font-size: 0.98rem;
}

.faq-q::before {
  content: "Q";
  color: var(--primary);
  font-weight: 700;
  flex: none;
}

.faq-a {
  color: var(--text-secondary);
  padding-left: 22px;
  line-height: 1.7;
  font-size: 14px;
}

.lang-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.lang-list a {
  color: var(--text-secondary);
}

.lang-list a:hover {
  color: var(--primary);
}

.root-lang-list {
  columns: 2;
  max-width: 420px;
  padding-left: 1.2rem;
}

.related-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-secondary);
  font-size: 14px;
}

.related-list a {
  color: var(--primary);
  font-weight: 500;
}

.tool-mount:empty::before {
  content: '';
  display: block;
  min-height: 8px;
}

.tool-head h1 {
  margin: 8px 0 6px;
  font-size: 1.5rem;
}

.tool-intro {
  color: var(--text-secondary);
  margin: 0 0 18px;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.breadcrumb a:hover {
  color: var(--primary);
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.panel label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

textarea,
input[type='text'],
input[type='number'],
input[type='search'],
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-page);
  color: var(--text-primary);
  font: inherit;
  padding: 10px 12px;
  -webkit-appearance: none;
  appearance: none;
}

textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 9px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.lang-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn:hover {
  filter: brightness(1.03);
}

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  font-size: 14px;
}

.options-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text-primary);
}

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text-primary);
  color: var(--bg-card);
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: 0.2s ease;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.success {
  background: #059669;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .logo-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}
