:root {
  color-scheme: light;
  --background: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f2f4f7;
  --text: #202124;
  --text-muted: #667085;
  --border: #d9dde5;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --on-primary: #ffffff;
  --danger: #d03050;
  --shadow: 0 8px 24px rgb(16 24 40 / 7%);
  --radius: 12px;
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

:root.dark {
  color-scheme: dark;
  --background: #101014;
  --surface: #18181c;
  --surface-muted: #242429;
  --text: #f4f4f5;
  --text-muted: #a4a7ae;
  --border: #38383f;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: #252b52;
  --on-primary: #0b1020;
  --danger: #e88080;
  --shadow: 0 8px 24px rgb(0 0 0 / 28%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.site-header {
  display: flex;
  width: min(1120px, calc(100% - 32px));
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.main-site-links {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-site-links::-webkit-scrollbar {
  display: none;
}

.main-site-links a {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.main-site-links a:hover,
.main-site-links a:focus-visible,
.main-site-links a[aria-current='page'] {
  color: var(--primary);
  background: var(--primary-soft);
}

.header-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-actions {
  flex: 0 0 auto;
}

.button,
button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.button:hover,
button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.button.primary,
button.primary {
  border-color: var(--primary);
  color: var(--on-primary);
  background: var(--primary);
}

.button.primary:hover,
button.primary:hover {
  border-color: var(--primary-hover);
  color: var(--on-primary);
  background: var(--primary-hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.theme-toggle {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-muted);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
  stroke: currentcolor;
}

.theme-toggle [data-mode-icon='dark'] {
  display: none;
}

:root.dark .theme-toggle [data-mode-icon='light'] {
  display: none;
}

:root.dark .theme-toggle [data-mode-icon='dark'] {
  display: block;
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 10px;
}

.tool-container {
  width: min(880px, calc(100% - 32px));
}

.hero {
  max-width: 760px;
  margin: 0 auto 34px;
  text-align: center;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.2;
}

.subtitle,
.tool-description {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.7;
}

.search {
  width: min(620px, 100%);
  min-height: 48px;
  margin-top: 18px;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  background: var(--surface);
}

.search:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.category {
  margin-top: 34px;
}

.category h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

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

.tool-card {
  display: block;
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease;
}

.tool-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.tool-card h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.tool-card p {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.empty-state {
  display: none;
  margin: 42px 0;
  color: var(--text-muted);
  text-align: center;
}

.tool-heading {
  margin-bottom: 24px;
  text-align: center;
}

.card {
  margin-bottom: 18px;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card h2 {
  margin-bottom: 20px;
  font-size: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field > label,
.field-label {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea,
.output {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  background: var(--surface);
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.55;
}

textarea[readonly],
input[readonly],
.output {
  background: var(--surface-muted);
}

.mono,
code,
pre {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

.error {
  min-height: 20px;
  margin: -8px 0 12px;
  color: var(--danger);
  font-size: 13px;
}

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

.row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-field input[type='checkbox'] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.large-output {
  padding: 18px;
  color: var(--primary);
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 600;
  overflow-wrap: anywhere;
  text-align: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px;
  border-radius: 9px;
  background: var(--surface-muted);
  text-align: center;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.temperature-row,
.conversion-row,
.case-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.case-row {
  grid-template-columns: 130px minmax(0, 1fr) auto;
}

.conversion-row {
  grid-template-columns: 150px minmax(0, 1fr) auto;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 16px;
  border-radius: 8px;
  color: #fff;
  background: #202124;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.content-card {
  line-height: 1.75;
}

.content-card h2 {
  margin-top: 28px;
}

[hidden] {
  display: none !important;
}

.notice {
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  color: var(--text-muted);
  background: var(--surface-muted);
  line-height: 1.6;
}

.preview {
  display: grid;
  min-height: 40px;
  margin: 14px 0;
  place-items: center;
}

.preview img {
  max-width: 100%;
  max-height: 420px;
  border-radius: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(140px, auto) minmax(0, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}

.result-grid > * {
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  background: var(--surface);
  overflow-wrap: anywhere;
}

.status-category {
  margin: 32px 0;
}

.status-category > h2 {
  font-size: 20px;
}

.status-card {
  margin-bottom: 10px;
  padding-block: 16px;
}

.status-card h3 {
  margin-bottom: 6px;
}

.status-card p {
  margin-bottom: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.permission-table input[type='checkbox'] {
  width: 22px;
  min-height: 22px;
  accent-color: var(--primary);
}

.key-display {
  text-align: center;
}

.key-display:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
}

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

.info-item {
  min-width: 0;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.info-item span,
.info-item strong {
  display: block;
}

.info-item span {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.info-item strong {
  font-size: 16px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

details {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

details[open] summary {
  margin-bottom: 16px;
}

.markdown-preview {
  min-height: 80px;
  overflow-wrap: anywhere;
  line-height: 1.7;
}

.markdown-preview pre,
.scrollable {
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.markdown-preview img {
  max-width: 100%;
}

.progress {
  height: 10px;
  overflow: hidden;
  margin: 14px 0 20px;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.suite-grid,
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.suite-card {
  display: grid;
  gap: 8px;
  margin: 0;
  box-shadow: none;
}

.suite-card label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.media-card img,
.media-card video,
#camera-preview {
  display: block;
  width: 100%;
  max-height: 520px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: #000;
  object-fit: contain;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 8px;
  margin-bottom: 28px;
}

.emoji-button {
  min-width: 0;
  min-height: 52px;
  padding: 5px;
  font-size: 28px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.editor-toolbar button {
  min-height: 34px;
  padding: 6px 10px;
}

.rich-editor {
  min-height: 300px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: var(--surface);
  line-height: 1.6;
}

.rich-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.diff-list {
  display: grid;
  gap: 8px;
}

.diff-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  overflow-wrap: anywhere;
}

.diff-row.added,
.diff-output .added {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.diff-row.removed,
.diff-output .removed {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.diff-row.updated {
  border-color: #f0a020;
}

.diff-output {
  overflow: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.diff-output span {
  display: block;
  min-height: 22px;
  padding-inline: 12px;
  white-space: pre-wrap;
}

.token-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 8px;
  margin: 18px 0;
  text-align: center;
}

.token-row strong {
  color: var(--primary);
  font-size: 28px;
}

.diagram {
  overflow-x: auto;
}

.diagram svg {
  display: block;
  min-width: 100%;
  min-height: 60px;
}

.memo-content table {
  width: 100%;
  border-collapse: collapse;
}

.memo-content th,
.memo-content td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.memo-content code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-muted);
}

.native-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

@media (max-width: 700px) {
  .site-header {
    width: calc(100% - 24px);
  }

  .theme-toggle {
    width: 26px;
    height: 26px;
    min-height: 26px;
  }

  .theme-toggle svg {
    width: 13px;
    height: 13px;
  }

  .container,
  .tool-container {
    width: min(100% - 24px, 880px);
    padding-top: 28px;
  }

  .row,
  .row.three,
  .switch-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .temperature-row,
  .conversion-row,
  .case-row {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 16px;
  }

  .temperature-row .unit {
    display: none;
  }

  .case-row button,
  .conversion-row button {
    width: 100%;
  }

  .result-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }
}
