* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --background: #f7f9fc;
  --surface: #ffffff;
  --text: #172033;
  --muted: #667085;
  --border: #d9dee8;
  --primary: #2f63d7;
  --primary-hover: #2755bb;
  /* Brand primitives; existing action blue stays the accessible UI alias. */
  --brand-blue: #2f6fed;
  --brand-teal: #22b8a7;
  --color-brand-primary: var(--brand-blue);
  --color-brand-secondary: var(--brand-teal);
  --accent-teal: #146e65;
  --accent-warm: #92522a;
  --color-accent-warm: var(--accent-warm);
  --recommended-accent: var(--accent-warm);
  --favorite-active: var(--accent-warm);
  --surface-muted: #f5f6f8;
  --surface-warm: #faf7f2;
  --surface-success: #edf7f4;
  --border-control: #7d899c;
  --state-success: var(--accent-teal);
  --state-warning: #855400;
  --state-danger: #b42318;
  --state-info: #344f76;
  --focus-ring: var(--primary);
  --header-surface: rgb(255 255 255 / .97);
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 20px;
}

.brand {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
}

.language-button {
  text-decoration: none;
  min-height: 44px;
  min-width: 48px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.container {
  width: min(920px, calc(100% - 32px));
  margin: 28px auto 64px;
}

.hero {
  margin-bottom: 22px;
  text-align: center;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: -0.04em;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.tool-card,
.info {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-card {
  padding: 24px;
}

.textarea-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(56, 116, 249, 0.14);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 14px 0 20px;
}

.button {
  border: 0;
  border-radius: 11px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-hover);
}

.button.secondary {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
}

.stat-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}


.info {
  padding: 22px 24px;
}

.info h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.info p {
  margin: 0;
  color: var(--muted);
}

.site-footer {
  padding: 28px 16px 40px;
  text-align: center;
  color: var(--muted);
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 30px;
  margin-bottom: 18px;
}

.site-footer-nav a {
  display: inline-block;
}

@media (max-width: 560px) {
  .site-footer-nav {
    gap: 12px 22px;
    margin-bottom: 20px;
  }
}

.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;
}

@media (max-width: 760px) {
  .container {
    margin-top: 12px;
  }

  .tool-card {
    padding: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat:last-child {
    grid-column: 1 / -1;
  }

  .actions {
    flex-direction: column-reverse;
  }

  .button {
    width: 100%;
  }
}


.input-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.input-heading .textarea-label {
  margin-bottom: 0;
}

.save-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.save-status.is-saving {
  color: #9a6700;
}

.save-status.is-saved {
  color: #15803d;
}

.draft-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 28px;
  margin-top: 8px;
}

.saved-at {
  color: var(--muted);
  font-size: 0.82rem;
}

.text-button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover {
  color: var(--text);
}

@media (max-width: 560px) {
  .input-heading {
    align-items: flex-start;
  }

  .draft-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}


textarea.is-expanded {
  resize: none;
}


.goal-panel {
  margin: 14px 0 4px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.goal-panel summary {
  width: fit-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
}

.goal-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.goal-controls label {
  font-size: 0.9rem;
  font-weight: 700;
}

.goal-controls input {
  width: 130px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
}

.goal-progress {
  margin-top: 12px;
}

.goal-progress-text {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ecf3;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.2s ease;
}

@media (max-width: 560px) {
  .goal-controls {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}


.reading-view {
  min-height: 260px;
  padding: 34px clamp(20px, 5vw, 56px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  outline: none;
}

.reading-view:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(56, 116, 249, 0.10);
}

.reading-content {
  max-width: 720px;
  margin: 0 auto;
  color: var(--text);
  font-size: clamp(1rem, 1.2vw, 1.08rem);
  line-height: 1.95;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.reading-view.is-empty .reading-content {
  color: var(--muted);
}

@media (max-width: 560px) {
  .reading-view {
    padding: 24px 18px;
  }

  .reading-content {
    line-height: 1.85;
  }
}

.brand-mark{display:inline-flex;align-items:center;gap:10px}
.brand-symbol{display:inline-grid;width:30px;height:30px;place-items:center;border-radius:9px;background:var(--primary);color:#fff;font-weight:900}
.language-link{min-width:54px;text-align:center}
.notice-box{margin-top:18px;padding:14px 16px;border:1px solid var(--border);border-radius:12px;background:var(--background);color:var(--muted);font-size:.9rem}

.brand {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.brand picture {
  display: block;
  line-height: 0;
}
.brand-logo {
  display: block;
  width: 190px;
  height: auto;
}
.contact-email {
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
  user-select: text;
}
@media (max-width: 560px) {
  .site-header {
    padding: 14px 16px;
  }
  .brand-logo {
    width: 155px;
  }
}

/* Portal home */
.home-main {
  padding-top: clamp(40px, 8vw, 88px);
  padding-bottom: 80px;
}
.home-hero {
  max-width: 820px;
  margin: 0 auto 56px;
  text-align: center;
}
.home-hero h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.85rem, 4.2vw, 3.15rem);
  letter-spacing: -0.055em;
}
.home-hero p {
  margin: 18px auto 0;
  max-width: 640px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.8;
}
.tools-section {
  max-width: 900px;
  margin: 0 auto;
}
.tools-section > h2 {
  margin: 0 0 18px;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 20px;
}
.tool-link-card {
  display: flex;
  gap: 20px;
  padding: clamp(22px, 4vw, 30px);
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.tool-link-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 116, 249, .45);
  box-shadow: 0 16px 36px rgba(15, 23, 42, .11);
}
.tool-link-card:focus-visible {
  outline: 3px solid rgba(56, 116, 249, .3);
  outline-offset: 3px;
}
.tool-icon {
  display: grid;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.35rem;
  border-radius: 15px;
  background: linear-gradient(145deg, #2f63d7, #168678);
}
.tool-link-body h3 {
  margin: 1px 0 8px;
  font-size: 1.25rem;
}
.tool-link-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}
.tool-open {
  display: inline-block;
  margin-top: 16px;
  color: var(--primary);
  font-weight: 700;
}
@media (max-width: 560px) {
  .home-main { padding-top: 36px; }
  .home-hero { margin-bottom: 40px; }
  .tool-link-card { gap: 15px; }
  .tool-icon { flex-basis: 50px; width: 50px; height: 50px; }
}

.home-support-copy {
  margin-bottom: 8px !important;
  color: var(--accent-teal) !important;
  font-weight: 700;
  font-size: clamp(.98rem, 1.8vw, 1.08rem) !important;
}
.cleaner-options {
  margin-bottom: 22px;
  padding: 24px;
}
.section-heading-row,
.editor-panel-header,
.save-status,
.result-actions {
  display: flex;
  align-items: center;
}
.section-heading-row,
.editor-panel-header,
.save-status {
  justify-content: space-between;
  gap: 16px;
}
.section-heading-row h2,
.editor-panel-header h2,
.prose-section h2 {
  margin: 0;
}
.section-heading-row > :first-child { min-width: 0; }
.section-heading-row > .text-button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.option-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
}
.option-item span {
  min-width: 0;
}
.option-item strong,
.option-item small {
  display: block;
}
.option-item strong {
  color: var(--text);
}
.option-item small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}
.cleaner-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.editor-panel {
  min-width: 0;
  padding: 20px;
}
.editor-panel-header {
  min-height: 52px;
  margin-bottom: 12px;
}
.editor-panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .92rem;
}
.editor-panel textarea {
  display: block;
  width: 100%;
  min-height: 440px;
  resize: vertical;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: 1rem;
  line-height: 1.8;
}
.editor-panel textarea:focus {
  outline: 3px solid rgba(56,116,249,.16);
  border-color: var(--primary);
}
.editor-panel textarea[readonly] {
  background: #fbfcfe;
}
.save-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: .9rem;
}
.result-actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.difference-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--primary);
  background: rgba(56,116,249,.1);
  font-size: .84rem;
  font-weight: 700;
}
.text-button {
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.danger-text {
  color: #a33a3a;
}
.prose-section {
  margin-top: 22px;
  padding: 24px;
}
.prose-section p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.8;
}
@media (max-width: 800px) {
  .option-grid,
  .cleaner-workspace {
    grid-template-columns: 1fr;
  }
  .editor-panel textarea {
    min-height: 330px;
  }
}
@media (max-width: 560px) {
  .cleaner-options,
  .editor-panel,
  .prose-section { padding: 17px; }
  .option-item { padding: 12px; }
  .section-heading-row,
  .editor-panel-header {
    align-items: flex-start;
  }
  .editor-panel-header { flex-wrap: wrap; }
  .editor-panel-header > * { min-width: 0; max-width: 100%; }
  .difference-badge { overflow-wrap: anywhere; }
  .segmented-control label { min-width: 0; }
  .segmented-control span { overflow-wrap: anywhere; }
  .utility-input-card > fieldset { min-width: 0; max-width: 100%; }
}

/* Rakuruno shared UI rules */
:root {
  --ui-radius-card: 18px;
  --ui-radius-control: 12px;
  --ui-card-padding: clamp(20px, 3vw, 28px);
  --ui-section-gap: 22px;
  --ui-heading-size: clamp(1.25rem, 2.4vw, 1.55rem);
  --ui-body-size: 1rem;
  --ui-small-size: .92rem;
}

.card,
.tool-link-card,
.tool-info-section {
  border-radius: var(--ui-radius-card);
}

.card,
.tool-info-section {
  padding: var(--ui-card-padding);
}

.tool-info-section {
  max-width: 100%;
  margin-top: var(--ui-section-gap);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-info-section > h2 {
  margin: 0 0 18px;
  font-size: var(--ui-heading-size);
  line-height: 1.35;
}

.tool-info-section > p {
  margin: 0;
  color: var(--muted);
  font-size: var(--ui-body-size);
  line-height: 1.8;
}

.related-tool-grid {
  grid-template-columns: minmax(0, 1fr);
}

.related-tool-grid .tool-link-card {
  width: 100%;
  box-sizing: border-box;
}

.option-item,
.editor-panel textarea,


/* Homepage hero alignment with tool pages */
.home-main {
  padding-top: 28px;
  padding-bottom: 80px;
}

.home-hero {
  max-width: min(1120px, calc(100vw - 32px));
  width: min(1120px, calc(100vw - 32px));
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  margin: 0 auto 42px;
  text-align: center;
}

.home-hero h1 {
  margin: 0;
}

.home-hero .home-support-copy {
  margin-top: 14px !important;
}

.home-hero p:last-child {
  margin-top: 10px;
}
@media (min-width: 1400px) {
  .home-hero p:last-child { max-width: 100%; }
}

.tool-grid {
  align-items: stretch;
}

.tool-link-card {
  min-height: 100%;
}

.tool-link-body {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
}

.tool-link-body p {
  flex: 1;
}

.tool-link-body .tool-open {
  margin-top: 18px;
}

.tool-icon-small {
  font-size: 1rem;
  letter-spacing: -.04em;
}

.sort-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.sort-row label {
  font-weight: 700;
}

.sort-row select {
  min-height: 42px;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  color: var(--text);
  background: #fff;
  font: inherit;
}

@media (max-width: 560px) {
  .home-main {
    padding-top: 24px;
  }

  .home-hero {
    margin-bottom: 34px;
  }

  .sort-row {
    align-items: stretch;
    flex-direction: column;
  }
}


/* Final homepage title-position fix:
   The shared .container margin supplies the page-top offset. */
.home-main {
  padding-top: 0;
}

@media (max-width: 560px) {
  .home-main {
    padding-top: 0;
  }
}

.tool-icon-wide {
  font-size: .78rem;
  letter-spacing: -.09em;
}
.direction-fieldset {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}
.direction-fieldset legend {
  margin-bottom: 10px;
  font-weight: 700;
}
.segmented-control {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #f3f6fb;
}
.segmented-control label {
  cursor: pointer;
}
.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented-control span {
  display: block;
  min-width: 132px;
  padding: 10px 16px;
  border-radius: 9px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.segmented-control input:checked + span {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(56,116,249,.18);
}
.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(56,116,249,.25);
  outline-offset: 2px;
}
@media (max-width: 560px) {
  .segmented-control {
    display: flex;
    width: 100%;
  }
  .segmented-control label {
    flex: 1;
  }
  .segmented-control span {
    min-width: 0;
    padding-inline: 10px;
  }
}


/* Width converter compact option cards */
.width-converter-page .option-grid {
  align-items: start;
}

.width-converter-page .option-item {
  min-height: 0;
  padding: 16px 18px;
}

.width-converter-page .option-item strong {
  font-size: 1rem;
}

.width-converter-page .option-item small {
  margin-top: 4px;
  font-size: .9rem;
  line-height: 1.45;
}

.width-converter-page .cleaner-options {
  padding-bottom: 22px;
}

@media (max-width: 560px) {
  .width-converter-page .option-item {
    padding: 14px 15px;
  }
}

.case-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
  margin-top: 18px;
}
.case-mode {
  position: relative;
  cursor: pointer;
}
.case-mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.case-mode span {
  display: block;
  height: 100%;
  min-height: 86px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.case-mode strong,
.case-mode small {
  display: block;
}
.case-mode small {
  margin-top: 6px;
  color: var(--muted);
}
.case-mode input:checked + span {
  border-color: var(--primary);
  background: rgba(56,116,249,.07);
  box-shadow: 0 0 0 2px rgba(56,116,249,.1);
}
.case-mode input:focus-visible + span {
  outline: 3px solid rgba(56,116,249,.25);
  outline-offset: 2px;
}
.faq-list {
  display: grid;
  gap: 10px;
}
.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}
.faq-list summary {
  position: relative;
  padding: 15px 46px 15px 16px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
  list-style: none;
}
.faq-list summary::-webkit-details-marker {
  display: none;
}
.faq-list summary::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 17px;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 1.3rem;
}
.faq-list details[open] summary::after {
  content: "−";
}
.faq-list details p {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--muted);
  line-height: 1.75;
}

/* FAQ heading stays visible; each question remains a native disclosure. */
.faq-section {
  margin-top: var(--ui-section-gap);
}

.faq-group {
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.faq-group > h2 {
  position: relative;
  padding: var(--ui-card-padding);
  margin: 0;
  color: var(--text);
  font-size: var(--ui-heading-size);
  font-weight: 700;
  line-height: 1.35;
  border-bottom: 1px solid var(--border);
}

.faq-group-content {
  padding: 16px var(--ui-card-padding) var(--ui-card-padding);
}


.diff-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.diff-input-grid textarea {
  min-height: 320px;
}
.diff-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin: 14px 0 22px;
}
.diff-result {
  padding: var(--ui-card-padding);
}
.diff-result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}
.diff-result-header h2 {
  margin: 0;
}
.diff-result-header p {
  margin: 7px 0 0;
  color: var(--muted);
}
.diff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: .9rem;
}
.diff-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.diff-legend i {
  width: 13px;
  height: 13px;
  border-radius: 4px;
}
.legend-added { background: #dff7e7; }
.legend-removed { background: #fde4e4; }
.legend-changed { background: #fff2cc; }
.diff-output {
  display: grid;
  gap: 8px;
}
.diff-empty {
  margin: 0;
  padding: 22px;
  border: 1px dashed var(--border);
  border-radius: var(--ui-radius-control);
  color: var(--muted);
  text-align: center;
}
.diff-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
}
.diff-row-changed {
  grid-template-columns: 44px repeat(2, minmax(0, 1fr));
}
.diff-line-number {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 13px 8px;
  color: var(--muted);
  background: #f4f6fa;
  font-size: .82rem;
}
.diff-cell {
  min-width: 0;
  padding: 12px 14px;
  border-left: 1px solid var(--border);
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.diff-row-changed .diff-cell + .diff-cell {
  border-left: 1px solid var(--border);
}
.diff-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
}
.diff-row-added { background: #f2fbf5; }
.diff-row-removed { background: #fff5f5; }
.diff-row-changed { background: #fffaf0; }
.char-added,
.char-removed {
  padding: 1px 2px;
  border-radius: 3px;
  color: inherit;
}
.char-added { background: #bdecc9; }
.char-removed { background: #f7c2c2; }
@media (max-width: 800px) {
  .diff-input-grid {
    grid-template-columns: 1fr;
  }
  .diff-result-header,
  .diff-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .diff-row-changed {
    grid-template-columns: 40px minmax(0, 1fr);
  }
  .diff-row-changed .diff-cell:nth-child(3) {
    grid-column: 2;
    border-top: 1px solid var(--border);
  }
}

/* Compact text-difference result */
.diff-output {
  gap: 10px;
}

.diff-row,
.diff-row-changed {
  display: none;
}

.diff-entry {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}

.diff-entry-number {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px 7px;
  color: var(--muted);
  background: #f4f6fa;
  font-size: .82rem;
}

.diff-entry-content {
  min-width: 0;
  border-left: 1px solid var(--border);
}

.diff-compact-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 11px 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-compact-line + .diff-compact-line {
  border-top: 1px solid var(--border);
}

.diff-compact-line .diff-label {
  margin: 0;
  padding-top: 1px;
}

.diff-entry-added .diff-entry-content {
  background: #f2fbf5;
}

.diff-entry-removed .diff-entry-content {
  background: #fff5f5;
}

.diff-entry-changed .diff-entry-content {
  background: #fffaf0;
}

.diff-before-line {
  background: rgba(253, 228, 228, .45);
}

.diff-after-line {
  background: rgba(223, 247, 231, .45);
}

@media (max-width: 560px) {
  .diff-entry {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .diff-compact-line {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 12px;
  }
}

/* Text difference checker: compact comparison option cards */
.text-diff-page .option-grid {
  align-items: start;
}

.text-diff-page .option-item {
  min-height: 0;
  padding: 15px 17px;
}

.text-diff-page .option-item input {
  flex: 0 0 auto;
  margin-top: 2px;
}

.text-diff-page .option-item strong {
  font-size: 1rem;
  line-height: 1.4;
}

.text-diff-page .option-item small {
  margin-top: 4px;
  font-size: .9rem;
  line-height: 1.45;
}

.text-diff-page .cleaner-options {
  padding-bottom: 22px;
}

@media (max-width: 560px) {
  .text-diff-page .option-item {
    padding: 13px 14px;
  }
}

/* Text difference checker: equal option-card heights */
.text-diff-page .option-grid {
  align-items: stretch;
}

.text-diff-page .option-item {
  height: 100%;
  box-sizing: border-box;
}

.replace-rules {
  padding: var(--ui-card-padding);
  margin-bottom: 22px;
}
.section-lead {
  margin: 7px 0 0;
  color: var(--muted);
}
.rules-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.replace-rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}
.replace-rule label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}
.replace-rule input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  font: inherit;
}
.replace-rule input:focus {
  outline: 3px solid rgba(56,116,249,.16);
  border-color: var(--primary);
}
.replace-arrow {
  padding-bottom: 11px;
  color: var(--muted);
  font-size: 1.15rem;
}
.rule-remove-button {
  width: 40px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #a33a3a;
  background: #fff;
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}
.add-rule-button {
  margin-top: 14px;
}
.advanced-settings {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}
.advanced-settings > summary {
  position: relative;
  padding: 14px 44px 14px 15px;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.advanced-settings > summary::-webkit-details-marker {
  display: none;
}
.advanced-settings > summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  color: var(--primary);
}
.advanced-settings[open] > summary::after {
  content: "−";
}
.advanced-settings-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}
.compact-option {
  min-height: 0 !important;
  padding: 13px 14px !important;
}
.replace-preview {
  margin-top: 22px;
  padding: var(--ui-card-padding);
}
.replace-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}
.replace-preview-header h2 {
  margin: 0;
}
.replace-preview-header p {
  margin: 7px 0 0;
  color: var(--muted);
}
.replace-preview-list {
  display: grid;
  gap: 10px;
}
.replace-preview-empty {
  margin: 0;
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--ui-radius-control);
  color: var(--muted);
  text-align: center;
}
.replace-match {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
  cursor: pointer;
}
.replace-match > input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--primary);
}
.replace-match-excluded {
  opacity: .62;
  background: #f7f8fb;
}
.replace-match-main {
  min-width: 0;
}
.replace-match-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 7px;
}
.replace-match-meta span {
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--primary);
  background: rgba(56,116,249,.08);
  font-size: .76rem;
  font-weight: 700;
}
.replace-match-context {
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.replace-before {
  padding: 1px 3px;
  border-radius: 4px;
  color: inherit;
  background: #ffe5a8;
}
.replace-match-change {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: .88rem;
}
.replace-match-change strong {
  color: var(--text);
}
@media (max-width: 760px) {
  .replace-rule {
    grid-template-columns: 1fr;
  }
  .replace-arrow {
    display: none;
  }
  .rule-remove-button {
    width: 100%;
  }
  .advanced-settings-content {
    grid-template-columns: 1fr;
  }
  .replace-preview-header {
    align-items: stretch;
    flex-direction: column;
  }
}


/* Rakuruno expansion: shared rules for the 10-tool release */
.tool-category { margin-top: 32px; }
.tool-category:first-of-type { margin-top: 18px; }
.tool-category > h3 { margin: 0 0 14px; font-size: 1.1rem; letter-spacing: -.015em; }
.tool-options { margin-bottom: 22px; padding: var(--ui-card-padding); }
.tool-options h2 { margin: 0; }
.compact-control-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-top: 18px; align-items: stretch; }
.field-control { display: grid; align-content: start; gap: 7px; padding: 14px 15px; border: 1px solid var(--border); border-radius: var(--ui-radius-control); background: #fff; color: var(--muted); font-size: .88rem; font-weight: 700; }
.field-control input,.field-control select { width:100%; min-height:42px; padding:9px 11px; border:1px solid var(--border); border-radius:9px; background:#fff; color:var(--text); font:inherit; font-weight:400; }
.field-control input:focus,.field-control select:focus { outline:3px solid rgba(56,116,249,.16); border-color:var(--primary); }
.compact-inline-options { display:flex; flex-wrap:wrap; gap:12px 24px; margin-top:16px; color:var(--text); }
.compact-inline-options label { display:inline-flex; align-items:center; gap:7px; }
.compact-inline-options input { width:17px; height:17px; accent-color:var(--primary); }
.tool-hint { margin:14px 0 0; color:var(--muted); font-size:.92rem; }
.inline-error { min-height:1.5em; margin:12px 0 0; color:#b42318; font-size:.9rem; }
.status-success { color:#15803d; background:rgba(21,128,61,.09); }
.status-error { color:#b42318; background:rgba(180,35,24,.09); }
.codec-mode,.json-mode { margin-top:18px; }
.codec-options { margin-top:16px; }
.codec-extra-grid { margin-top:18px; }
.line-mode-control { margin-top:18px; }
.line-number-controls.is-disabled .field-control,.line-number-controls.is-disabled .option-item { opacity:.48; pointer-events:none; }
.filter-query-row { display:grid; grid-template-columns:minmax(0,1.5fr) repeat(2,minmax(0,1fr)); gap:12px; margin-top:18px; }
.analysis-workspace { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:22px; }
.frequency-panel { padding:var(--ui-card-padding); min-width:0; }
.frequency-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:14px; }
.frequency-header h2 { margin:0; } .frequency-header p { margin:6px 0 0; color:var(--muted); }
.frequency-table-wrap { overflow:auto; border:1px solid var(--border); border-radius:var(--ui-radius-control); }
.frequency-table { width:100%; border-collapse:collapse; background:#fff; }
.frequency-table th,.frequency-table td { padding:10px 12px; border-bottom:1px solid var(--border); text-align:left; white-space:nowrap; }
.frequency-table th { color:var(--muted); background:#f7f8fb; font-size:.82rem; }
.frequency-table tr:last-child td { border-bottom:0; }
.table-empty { padding:24px!important; color:var(--muted); text-align:center!important; }
.related-tool-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr)); }
@media (max-width:800px) { .compact-control-grid,.analysis-workspace,.filter-query-row { grid-template-columns:1fr; } .frequency-header { flex-direction:column; align-items:stretch; } }
@media (max-width:560px) { .tool-category { margin-top:26px; } .field-control { padding:12px 13px; } }

/* Final shared surface and button rules */
.card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 11px;
  font: inherit;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: #fff;
}

.secondary-button:hover {
  border-color: rgba(56, 116, 249, .45);
  background: #f8faff;
}

.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: 3px solid rgba(56, 116, 249, .24);
  outline-offset: 2px;
}

/* Word-frequency results should grow with content instead of reserving empty height */
.analysis-workspace {
  align-items: start;
}

/* Safe QR Code Generator */
.qr-generator-page .qr-section-copy {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: var(--ui-small-size);
}

.qr-generator-page .qr-type-control {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  margin-top: 18px;
}

.qr-generator-page .qr-type-control label,
.qr-generator-page .qr-type-control span {
  min-width: 0;
}

.qr-generator-page .qr-type-control span {
  padding-inline: 10px;
}

.qr-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr);
  align-items: start;
  gap: 22px;
}

.qr-input-panel,
.qr-preview-panel {
  min-width: 0;
  padding: var(--ui-card-padding);
}

.qr-mode-panel[hidden],
.qr-generator-page [hidden] {
  display: none !important;
}

.qr-generator-page .field-control {
  color: var(--text);
}

.qr-generator-page .field-control > span,
.qr-generator-page .field-control > label {
  font-size: .9rem;
  font-weight: 700;
}

.qr-generator-page .field-control textarea {
  min-height: 128px;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
}

.qr-generator-page .field-control textarea:focus {
  outline: 3px solid rgba(56, 116, 249, .16);
  border-color: var(--primary);
  box-shadow: none;
}

.qr-generator-page .field-control small {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 400;
  line-height: 1.55;
}

.qr-field-stack {
  display: grid;
  gap: 12px;
}

.qr-wifi-options {
  margin-top: 0;
}

.qr-password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.qr-compact-button {
  min-height: 42px;
  white-space: nowrap;
}

.qr-checkbox-option {
  align-self: stretch;
  margin: 0;
}

.qr-invert-option {
  margin-top: 0;
}

.qr-character-count {
  margin: 8px 2px 0;
  color: var(--muted);
  text-align: right;
  font-size: .86rem;
}

.qr-inline-notice {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  color: #8a4b08;
  background: #fff7e8;
  font-size: .88rem;
  line-height: 1.6;
}

.qr-preview-surface {
  display: grid;
  min-height: 320px;
  padding: 18px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #f7f8fb;
}

.qr-preview-surface canvas {
  display: block;
  max-width: 100%;
  height: auto !important;
  image-rendering: pixelated;
  box-shadow: 0 4px 18px rgba(15, 23, 42, .08);
}

.qr-preview-surface > p {
  max-width: 28rem;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.qr-review,
.qr-readability {
  margin-top: 16px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}

.qr-review-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.qr-review h3,
.qr-readability h3 {
  margin: 0;
  font-size: 1rem;
}

.qr-confirmation dl {
  display: grid;
  gap: 9px;
  margin: 12px 0 0;
}

.qr-confirmation-row {
  display: grid;
  grid-template-columns: minmax(105px, .36fr) minmax(0, 1fr);
  gap: 12px;
}

.qr-confirmation dt {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}

.qr-confirmation dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: .9rem;
}

.qr-confirmation-multiline {
  white-space: pre-wrap;
}

.qr-empty-copy,
.qr-readability p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.qr-readability ul {
  margin: 10px 0 0;
  padding-left: 1.25rem;
  color: #8a4b08;
  font-size: .9rem;
}

.qr-readability.is-good {
  border-color: rgba(21, 128, 61, .28);
  background: rgba(21, 128, 61, .06);
}

.qr-readability.is-good p {
  color: #15803d;
  font-weight: 700;
}

.qr-readability.is-warning {
  border-color: rgba(180, 83, 9, .25);
  background: #fffaf2;
}

.qr-download-actions {
  margin-top: 16px;
}

.qr-download-actions button {
  flex: 1 1 140px;
}

.qr-download-actions button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.qr-settings {
  margin-top: 22px;
}

.qr-notice-list {
  margin: 0;
  padding-left: 1.3rem;
  color: var(--muted);
  line-height: 1.8;
}

.qr-license-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

@media (max-width: 800px) {
  .qr-generator-page .qr-type-control {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .qr-workspace {
    grid-template-columns: 1fr;
  }

  .qr-preview-surface {
    min-height: 280px;
  }
}

@media (max-width: 560px) {
  .qr-generator-page .qr-type-control {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qr-generator-page .qr-type-control label:last-child {
    grid-column: 1 / -1;
  }

  .qr-input-panel,
  .qr-preview-panel {
    padding: 17px;
  }

  .qr-password-row,
  .qr-confirmation-row {
    grid-template-columns: 1fr;
  }

  .qr-preview-surface {
    min-height: 230px;
    padding: 12px;
  }

  .qr-review-heading-row {
    flex-direction: column;
    gap: 5px;
  }
}

/* Image Optimizer & Converter */
.image-optimizer-page .card { min-width: 0; }
.optimizer-upload-card { margin-bottom: 20px; }
.optimizer-upload-card .section-heading-row p,
.optimizer-settings-card .section-heading-row p,
.optimizer-list-card .section-heading-row p { margin: 4px 0 0; color: var(--muted); }
.optimizer-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 22px;
  border: 2px dashed #b8c3cc;
  border-radius: 14px;
  background: #f8fafb;
  text-align: center;
  transition: border-color .18s ease, background .18s ease;
}
.optimizer-drop-zone.is-dragging { border-color: var(--primary); background: #eff8ff; }
.optimizer-drop-zone strong { font-size: 1.05rem; }
.optimizer-drop-zone small { color: var(--muted); }
.optimizer-drop-icon { color: var(--primary); font-size: 1.8rem; line-height: 1; }
.optimizer-privacy-note {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: .88rem;
}
.optimizer-privacy-note p { margin: 0; }
.optimizer-workspace {
  display: grid;
  grid-template-columns: minmax(310px, .82fr) minmax(0, 1.45fr);
  grid-template-areas:
    "list preview"
    "settings settings";
  gap: 20px;
  align-items: start;
}
.optimizer-list-card { grid-area: list; }
.optimizer-preview-card { grid-area: preview; }
.optimizer-settings-card { grid-area: settings; }
.optimizer-empty-list { margin: 14px 0 0; color: var(--muted); text-align: center; }
.optimizer-file-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  max-height: 520px;
  overflow: auto;
}
.optimizer-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.optimizer-file-item.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(56, 116, 249, .12); }
.optimizer-file-item.has-error { border-color: #e6a39c; }
.optimizer-file-select {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.optimizer-file-select img {
  width: 58px;
  height: 58px;
  border-radius: 9px;
  background: #eef2f4;
  object-fit: cover;
}
.optimizer-file-details { display: grid; min-width: 0; gap: 2px; }
.optimizer-file-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.optimizer-file-details span,
.optimizer-file-details small { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.optimizer-file-status { overflow-wrap: anywhere; }
.optimizer-file-item.has-error .optimizer-file-status { color: #b42318; }
.optimizer-file-actions { display: grid; justify-items: end; gap: 2px; }
.optimizer-file-actions .text-button { padding: 5px 7px; font-size: .78rem; }
.optimizer-file-actions .text-button:disabled { opacity: .45; cursor: not-allowed; }
.optimizer-batch-actions { flex-wrap: wrap; margin-top: 14px; }
.optimizer-batch-actions button { flex: 1 1 180px; }
.optimizer-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.optimizer-preview-pane { min-width: 0; margin: 0; }
.optimizer-preview-pane figcaption { margin-bottom: 7px; font-weight: 700; }
.optimizer-preview-surface {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: #f5f7f8;
  background-image:
    linear-gradient(45deg, #e7ebed 25%, transparent 25%),
    linear-gradient(-45deg, #e7ebed 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7ebed 75%),
    linear-gradient(-45deg, transparent 75%, #e7ebed 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.optimizer-preview-surface img { display: block; width: 100%; height: 100%; object-fit: contain; }
.optimizer-preview-surface p { margin: 0; padding: 14px; color: var(--muted); text-align: center; }
.optimizer-comparison { margin-top: 16px; }
.optimizer-comparison h3 { margin: 0 0 9px; font-size: 1rem; }
.optimizer-comparison dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.optimizer-comparison dl div { padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafb; }
.optimizer-comparison dt { color: var(--muted); font-size: .78rem; }
.optimizer-comparison dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.optimizer-notices { display: grid; gap: 7px; margin-top: 12px; }
.optimizer-notice { margin: 0; padding: 9px 11px; border-radius: 9px; font-size: .88rem; }
.optimizer-notice.is-success { background: #edf8f1; color: #1d6b3b; }
.optimizer-notice.is-warning { background: #fff6e8; color: #8a4b08; }
.optimizer-notice.is-neutral { background: #f2f5f7; color: var(--muted); }
.optimizer-presets { margin: 16px 0 0; padding: 0; border: 0; }
.optimizer-presets legend { margin-bottom: 8px; font-weight: 700; }
.optimizer-preset-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.optimizer-preset-buttons button { display: grid; gap: 3px; align-content: start; height: auto; padding: 10px; text-align: left; }
.optimizer-preset-buttons button[aria-pressed="true"] { border-color: var(--primary); background: #eff8ff; color: var(--primary-hover); }
.optimizer-preset-buttons small { color: var(--muted); font-weight: 400; line-height: 1.35; }
.optimizer-format-controls,
.optimizer-resize-controls { margin-top: 14px; }
.optimizer-quality-control input[type="range"] { width: 100%; }
.optimizer-quality-control.is-disabled { opacity: .55; }
.optimizer-quality-control small { min-height: 1.2em; color: var(--muted); }
.optimizer-option-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.optimizer-settings-card .save-status { margin-top: 14px; }

@media (max-width: 920px) {
  .optimizer-workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "list"
      "preview"
      "settings";
  }
  .optimizer-file-list { max-height: none; }
}

@media (max-width: 620px) {
  .optimizer-drop-zone { padding: 18px 12px; }
  .optimizer-preview-grid,
  .optimizer-comparison dl,
  .optimizer-preset-buttons,
  .optimizer-option-list { grid-template-columns: 1fr; }
  .optimizer-file-item { grid-template-columns: minmax(0, 1fr); }
  .optimizer-file-actions { grid-template-columns: repeat(2, auto); justify-content: end; }
  .optimizer-batch-actions { flex-direction: column; }
  .optimizer-batch-actions button { flex-basis: auto; width: 100%; }
  .optimizer-preview-surface { aspect-ratio: 16 / 10; }
}

/* Password generator */
.password-result-card { padding: var(--ui-card-padding); }
.password-result-heading { align-items: flex-start; }
.password-result-heading h2 { margin: 0; }
.password-result-heading p { margin: 6px 0 0; color: var(--muted); }
.password-result-actions { flex-wrap: wrap; margin-top: 0; }
.password-value {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 3.5rem;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #f8fafb;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.1rem, 2.6vw, 1.45rem);
  font-weight: 700;
  letter-spacing: .035em;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.password-action-status { min-height: 1.3em; margin: 8px 0 0; color: var(--primary-hover); font-size: .9rem; font-weight: 700; }
.password-strength { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 5px; color: var(--muted); font-size: .92rem; }
.password-strength strong { color: var(--text); }
.password-strength-bars { display: inline-flex; gap: 4px; }
.password-strength-bars i { display: block; width: 18px; height: 6px; border-radius: 999px; background: #dce3e8; }
.password-strength-bars i.is-active { background: var(--primary); }
.password-length-control { display: grid; gap: 8px; margin-top: 18px; color: var(--text); font-weight: 700; }
.password-length-control > span { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.password-length-control strong { color: var(--primary-hover); font-size: 1.25rem; }
.password-length-control input[type="range"] { width: 100%; min-height: 34px; accent-color: var(--primary); }
.password-length-control small { color: var(--muted); font-weight: 400; }
.password-character-options { margin: 20px 0 0; padding: 0; border: 0; }
.password-character-options legend { margin-bottom: 9px; color: var(--text); font-weight: 700; }
.password-option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.password-ambiguous-option { margin-top: 10px; }
.password-settings-notice { min-height: 1.3em; margin: 10px 0 0; color: #9a6700; font-size: .9rem; font-weight: 700; }
.password-generator-page .save-status { margin-top: 14px; }

@media (max-width: 620px) {
  .password-result-actions { width: 100%; }
  .password-result-actions button { flex: 1 1 130px; }
  .password-option-grid { grid-template-columns: 1fr; }
  .password-value { margin-top: 15px; padding: 13px; }
}

/* PDF merge and extraction */
.pdf-work-panel { padding: var(--ui-card-padding); }
.pdf-work-panel + .pdf-work-panel { margin-top: var(--ui-section-gap); }
.pdf-work-panel .section-heading-row { align-items: flex-start; }
.pdf-work-panel .section-heading-row h2 { margin: 0; }
.pdf-work-panel .section-heading-row p { margin: 5px 0 0; color: var(--muted); }
.pdf-mode-control { margin-top: 17px; }
.pdf-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 22px 16px;
  border: 1.5px dashed #b8c6d8;
  border-radius: var(--ui-radius-card);
  background: #fbfcfe;
  color: var(--muted);
  text-align: center;
  transition: border-color .18s ease, background .18s ease;
}
.pdf-drop-zone.is-dragging { border-color: var(--primary); background: #eff8ff; }
.pdf-drop-zone strong { color: var(--text); font-size: 1.03rem; }
.pdf-drop-zone small { color: var(--muted); }
.pdf-drop-icon { color: var(--primary); font-size: 1.85rem; line-height: 1; }
.pdf-privacy-note { margin: 12px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.6; }
.pdf-empty-state { margin: 18px 0 0; color: var(--muted); }
.pdf-file-list { display: grid; gap: 9px; margin: 16px 0 0; padding: 0; list-style: none; }
.pdf-file-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}
.pdf-file-item[draggable="true"] { cursor: grab; }
.pdf-file-item[draggable="true"]:active { cursor: grabbing; }
.pdf-order { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #eef3fb; color: var(--primary-hover); font-size: .86rem; font-weight: 800; }
.pdf-file-details { display: grid; min-width: 0; gap: 3px; }
.pdf-file-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-file-details small { color: var(--muted); font-size: .83rem; }
.pdf-file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; }
.pdf-file-actions .text-button { min-width: 31px; padding: 6px 7px; }
.pdf-output-options { max-width: 440px; margin-top: 16px; }
.pdf-extract-info { display: grid; gap: 4px; margin-top: 17px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--ui-radius-control); background: #f8fafb; }
.pdf-extract-info strong { overflow-wrap: anywhere; }
.pdf-extract-info span { color: var(--muted); font-size: .9rem; }
.pdf-extract-controls { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; margin-top: 16px; }
.pdf-page-summary { min-height: 1.35em; margin: 11px 0 0; color: var(--primary-hover); font-size: .9rem; font-weight: 700; }
.pdf-processing-status { min-height: 1.35em; margin: 10px 0 0; color: var(--muted); font-size: .9rem; font-weight: 700; }

@media (max-width: 620px) {
  .pdf-drop-zone { padding: 19px 13px; }
  .pdf-file-item { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .pdf-file-actions { grid-column: 1 / -1; justify-content: flex-start; padding-left: 39px; }
  .pdf-extract-controls { grid-template-columns: 1fr; }
}

/* Image to PDF */
.image-pdf-work-panel,
.image-pdf-settings { padding: var(--ui-card-padding); }
.image-pdf-settings { margin-top: var(--ui-section-gap); }
.image-pdf-work-panel .section-heading-row,
.image-pdf-settings .section-heading-row { align-items: flex-start; }
.image-pdf-work-panel .image-pdf-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: start;
  column-gap: 16px;
  row-gap: 5px;
}
.image-pdf-heading-row > h2 { grid-column: 1; min-width: 0; }
.image-pdf-heading-description { grid-column: 1 / -1; min-width: 0; }
.image-pdf-heading-row > .text-button {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  max-width: 100%;
  white-space: nowrap;
}
.image-pdf-work-panel .section-heading-row h2,
.image-pdf-settings .section-heading-row h2 { margin: 0; }
.image-pdf-work-panel .section-heading-row p,
.image-pdf-settings .section-heading-row p { margin: 5px 0 0; color: var(--muted); }
.image-pdf-file-list { display: grid; gap: 9px; margin: 16px 0 0; padding: 0; list-style: none; }
.image-pdf-file-item {
  display: grid;
  grid-template-columns: auto 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}
.image-pdf-file-item[draggable="true"] { cursor: grab; }
.image-pdf-file-item[draggable="true"]:active { cursor: grabbing; }
.image-pdf-order { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #eef3fb; color: var(--primary-hover); font-size: .86rem; font-weight: 800; }
.image-pdf-thumbnail { width: 54px; height: 54px; border-radius: 9px; background: #eef2f4; object-fit: cover; }
.image-pdf-file-info { display: grid; min-width: 0; gap: 3px; }
.image-pdf-file-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-pdf-file-info span { color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
.image-pdf-file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; }
.image-pdf-file-actions .text-button { min-width: 31px; padding: 6px 7px; }
.image-pdf-control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 17px; }
.image-pdf-settings .save-status { margin-top: 15px; }
.image-pdf-settings .result-actions { margin-top: 18px; }

@media (max-width: 620px) {
  .image-pdf-file-item { grid-template-columns: auto 48px minmax(0, 1fr); align-items: start; }
  .image-pdf-thumbnail { width: 48px; height: 48px; }
  .image-pdf-file-actions { grid-column: 1 / -1; justify-content: flex-start; padding-left: 0; }
  .image-pdf-control-grid { grid-template-columns: 1fr; }
}

/* Shared tool-page navigation */
.page-bottom-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: var(--ui-section-gap);
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
}
.page-bottom-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  color: var(--primary-hover);
  font-weight: 700;
  text-decoration: none;
}
.page-bottom-nav a:hover { text-decoration: underline; }
.page-bottom-nav a:focus-visible { outline: 3px solid rgba(56, 116, 249, .3); outline-offset: 3px; border-radius: 6px; }

/* Roulette & Random Picker */
.roulette-workspace { display: grid; grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr); gap: 20px; align-items: start; }
.roulette-input-card,
.roulette-wheel-card { padding: var(--ui-card-padding); min-width: 0; }
.roulette-input-card .section-heading-row { align-items: flex-start; }
.roulette-input-card .section-heading-row h2 { margin: 0; }
.roulette-input-card .section-heading-row p { margin: 5px 0 0; color: var(--muted); }
.roulette-input-card textarea { width: 100%; min-height: 185px; box-sizing: border-box; margin-top: 17px; resize: vertical; }
.roulette-input-card > small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.55; }
.roulette-duplicate-note { margin: 12px 0 0; color: #8a4b08; font-size: .9rem; line-height: 1.55; }
.roulette-remove-option { margin-top: 16px; }
.roulette-input-card .save-status { margin-top: 15px; }
.roulette-wheel-wrap { position: relative; width: min(100%, 560px); margin: 0 auto; }
.roulette-wheel-wrap canvas { display: block; width: 100%; height: auto; border-radius: 50%; }
.roulette-pointer { position: absolute; z-index: 1; top: -3px; left: 50%; width: 0; height: 0; transform: translateX(-50%); border-right: 15px solid transparent; border-left: 15px solid transparent; border-top: 27px solid #17233b; filter: drop-shadow(0 2px 1px rgba(15, 23, 42, .22)); }
.roulette-status { min-height: 1.35em; margin: 14px 0 0; color: var(--muted); font-size: .92rem; font-weight: 700; text-align: center; }
.roulette-status.is-error { color: #b42318; }
.roulette-actions { justify-content: center; flex-wrap: wrap; margin-top: 13px; }
.roulette-result { margin-top: 17px; padding: 15px; border: 1px solid #b9d1f8; border-radius: var(--ui-radius-control); background: #f2f7ff; text-align: center; }
.roulette-result h2 { margin: 0; color: var(--muted); font-size: .92rem; }
.roulette-result output { display: block; margin-top: 5px; color: var(--text); font-size: clamp(1.35rem, 3vw, 1.9rem); font-weight: 800; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .roulette-workspace { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .page-bottom-nav { flex-direction: column; align-items: flex-start; }
  .roulette-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .roulette-actions button { width: 100%; }
}

/* Date & Day Calculator */
.date-calculator-mode-card,
.date-calculator-panel { padding: var(--ui-card-padding); }
.date-calculator-panel { margin-top: var(--ui-section-gap); }
.date-calculator-mode-card h2,
.date-calculator-panel h2 { margin: 0; }
.date-calculator-panel > p { margin: 5px 0 0; color: var(--muted); }
.date-mode-fieldset { margin: 17px 0 0; padding: 0; border: 0; }
.date-mode-control { display: flex; width: 100%; }
.date-mode-control label { flex: 1 1 0; }
.date-mode-control span { min-width: 0; height: 100%; padding-inline: 12px; }
.date-calculator-panel[hidden] { display: none !important; }
.date-calculator-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 17px; }
.date-calculator-offset-form { grid-template-columns: minmax(0, 1.35fr) minmax(140px, .7fr) minmax(130px, .6fr); }
.date-input-row { display: flex; gap: 8px; min-width: 0; }
.date-input-row input { min-width: 0; }
.date-input-row .text-button { flex: 0 0 auto; min-height: 42px; padding-inline: 11px; white-space: nowrap; }
.date-calculator-result { margin-top: 17px; padding: 16px 17px; border: 1px solid #b9d1f8; border-radius: var(--ui-radius-control); background: #f2f7ff; }
.date-calculator-result h3 { margin: 0; color: var(--muted); font-size: .92rem; }
.date-calculator-result output { display: block; margin-top: 4px; color: var(--text); font-size: clamp(1.35rem, 3vw, 1.9rem); font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.date-calculator-result p { min-height: 1.4em; margin: 7px 0 0; color: var(--muted); font-size: .92rem; }
.date-calculator-result p.is-error { color: #b42318; }

/* Age Calculator */
.age-calculator-panel,
.age-calculator-result { padding: var(--ui-card-padding); }
.age-calculator-result { margin-top: var(--ui-section-gap); }
.age-calculator-panel h2,
.age-calculator-result h2 { margin: 0; }
.age-calculator-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 17px; }
.age-calculator-panel .field-help { margin: 11px 0 0; color: var(--muted); font-size: .9rem; }
.age-calculator-error { min-height: 1.4em; margin: 8px 0 0; color: #b42318; font-size: .9rem; font-weight: 700; }
.age-primary-result { display: block; margin-top: 9px; color: var(--text); font-size: clamp(2.2rem, 7vw, 3.45rem); font-weight: 850; line-height: 1.18; overflow-wrap: anywhere; }
.age-parts { margin: 7px 0 0; color: var(--primary-hover); font-size: clamp(1.05rem, 2vw, 1.25rem); font-weight: 750; }
.age-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.age-detail-grid section { min-width: 0; padding: 14px 15px; border: 1px solid var(--border); border-radius: var(--ui-radius-control); background: #f7f9fc; }
.age-detail-grid h3 { margin: 0; color: var(--muted); font-size: .9rem; }
.age-detail-value { margin: 5px 0 0; color: var(--text); font-size: 1.08rem; font-weight: 800; overflow-wrap: anywhere; }
.age-detail-note { min-height: 1.4em; margin: 4px 0 0; color: var(--muted); font-size: .88rem; }

@media (max-width: 720px) {
  .date-calculator-form,
  .date-calculator-offset-form,
  .age-calculator-form { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .date-mode-control span { padding: 9px 7px; font-size: .88rem; line-height: 1.35; }
  .date-calculator-result { padding: 15px; }
  .age-detail-grid { grid-template-columns: 1fr; }
}

/* Shared calculator and utility pages */
.utility-input-card,
.utility-result-card { padding: var(--ui-card-padding); }
.utility-input-card h2,
.utility-result-card h2 { margin: 0; }
.utility-result-card { margin-top: var(--ui-section-gap); }
.utility-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  align-items: start;
  margin-top: 17px;
}
.utility-field-wide { grid-column: 1 / -1; }
.utility-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  min-height: 42px;
}
.utility-checks label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-weight: 700;
}
.utility-checks input { width: auto; margin: 0; }
.business-mode-panel[hidden] { display: none; }
.business-weekly-days { flex-wrap: wrap; min-width: 0; }
.business-weekly-days label { min-height: 44px; min-width: 44px; }
.business-mode-panel + .utility-form-grid { margin-top: 13px; }
.utility-input-card > .segmented-control,
.utility-input-card > fieldset > .segmented-control { margin-top: 14px; }
.utility-input-card > .primary-button { min-height: 44px; margin-top: 16px; }
.utility-primary-result {
  display: block;
  margin-top: 9px;
  color: var(--text);
  font-size: clamp(1.65rem, 4vw, 2.5rem);
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.utility-result-formula,
.utility-result-detail { margin: 8px 0 0; color: var(--muted); line-height: 1.65; overflow-wrap: anywhere; }
.utility-result-detail { font-weight: 700; }
.tool-share {
  display: block;
  margin-top: var(--ui-section-gap);
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: #f8fafc;
  box-shadow: none;
}
.tool-share-heading { margin: 0; color: var(--muted); font-size: .9rem; font-weight: 700; }
.tool-share-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.tool-share-action {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  text-decoration: none;
}
.tool-share-icon { width: 44px; padding-inline: 0; color: var(--text); font-weight: 850; }
.share-status { min-height: 1.4em; margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.tool-share[hidden], .tool-share button[hidden] { display: none !important; }
.tool-share .text-button { min-height: 44px; }

/* Invisible character detector */
.invisible-character-page .invisible-input-card,
.invisible-character-page .invisible-output-card,
.invisible-character-page .invisible-results { margin-top: var(--ui-section-gap); }
.invisible-character-page .editor-panel textarea { min-height: 220px; }
.invisible-character-page button { min-height: 44px; }
.invisible-results { display: grid; gap: 18px; }
.invisible-results[hidden],
.invisible-output-card[hidden] { display: none; }
.invisible-summary,
.invisible-preview-card,
.invisible-types-card { padding: var(--ui-card-padding); }
.invisible-summary h2,
.invisible-preview-card h2,
.invisible-types-card h2 { margin: 0 0 10px; font-size: var(--ui-heading-size); }
.invisible-summary p,
.invisible-preview-card > p,
.invisible-types-card > p { margin: 0; color: var(--muted); line-height: 1.65; }
.invisible-summary strong { color: var(--text); font-size: 1.35rem; }
.invisible-preview {
  min-height: 82px;
  margin-top: 14px;
  padding: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fbfcfe;
  line-height: 1.8;
  unicode-bidi: plaintext;
}
.invisible-preview:focus-visible { outline: 3px solid rgba(56,116,249,.2); outline-offset: 2px; }
.invisible-marker {
  display: inline;
  padding: 2px 4px;
  border: 1px solid #c98719;
  border-radius: 5px;
  background: #fff4d6;
  color: #6f4100;
  font: 700 .78rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  unicode-bidi: isolate;
}
.invisible-type-list { display: grid; gap: 10px; margin: 16px 0; }
.invisible-type-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #fff;
}
.invisible-type-item input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); }
.invisible-type-item > span { min-width: 0; }
.invisible-type-item strong,
.invisible-type-detail,
.invisible-type-item small { display: block; overflow-wrap: anywhere; }
.invisible-type-detail { margin-top: 3px; color: var(--text); font-size: .9rem; }
.invisible-type-item small { margin-top: 4px; color: var(--muted); line-height: 1.5; }
.invisible-type-item .invisible-type-warning { color: #8a4b08; }
.invisible-status { min-height: 1.45em; margin: 10px 0 0; color: var(--primary-hover); font-size: .92rem; font-weight: 700; }
.invisible-status.is-error { color: #b42318; }

@media (max-width: 560px) {
  .invisible-character-page .invisible-input-card,
  .invisible-character-page .invisible-output-card,
  .invisible-summary,
  .invisible-preview-card,
  .invisible-types-card { padding: 17px; }
  .invisible-character-page .result-actions button { width: 100%; }
}

@media (max-width: 720px) {
  .utility-form-grid { grid-template-columns: 1fr; }
  .utility-field-wide { grid-column: auto; }
}

@media (max-width: 560px) {
  .tool-share-actions { display: grid; grid-template-columns: repeat(3, max-content); }
  html[lang="en"] .tool-share-actions { grid-template-columns: repeat(2, max-content); }
}

/* Random, list, and timer utilities */
.utility-output-list {
  max-height: 310px;
  margin: 12px 0 0;
  padding: 13px 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-control);
  background: #f7f9fc;
  color: var(--text);
  font: inherit;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.utility-result-card > h3 { margin: 18px 0 0; font-size: 1rem; }
.utility-team-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.utility-team-results section { min-width: 0; padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--ui-radius-control); background: #f7f9fc; }
.utility-team-results h3 { margin: 0; font-size: 1rem; }
.utility-team-results ol { margin: 9px 0 0; padding-left: 1.4em; }
.utility-team-results li { padding: 2px 0; overflow-wrap: anywhere; }
.utility-timer { margin-top: 10px; text-align: center; }
.utility-timer-display {
  display: block;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: clamp(2rem, 8vw, 4.2rem);
  font-weight: 850;
  letter-spacing: .025em;
  line-height: 1.2;
  white-space: nowrap;
}
.utility-timer-phase { margin: 10px 0 0; color: var(--primary-hover); font-size: 1.05rem; font-weight: 800; }
.utility-timer-status { min-height: 1.5em; margin: 7px 0 0; color: var(--muted); font-weight: 700; }

@media (max-width: 560px) {
  .utility-team-results { grid-template-columns: 1fr; }
  .utility-timer-display { font-size: clamp(1.7rem, 12vw, 3rem); }
  .utility-input-card .result-actions { display: grid; grid-template-columns: 1fr; }
  .utility-input-card .result-actions button { width: 100%; }
}

/* Data, color, and local media utilities */
.utility-table-wrap { max-height: 440px; margin-top: 13px; overflow: auto; border: 1px solid var(--border); border-radius: var(--ui-radius-control); }
.utility-table-wrap table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .9rem; }
.utility-table-wrap th,
.utility-table-wrap td { max-width: 320px; padding: 8px 10px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.utility-table-wrap th { position: sticky; top: 0; z-index: 1; background: #eef3fb; font-weight: 800; }
.color-preview { min-height: 120px; margin-top: 13px; border: 1px solid var(--border); border-radius: var(--ui-radius-control); background-image: linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; }
.contrast-sample { margin-top: 13px; padding: 22px 16px; border: 1px solid var(--border); border-radius: var(--ui-radius-control); font-size: 1.3rem; font-weight: 800; text-align: center; }
.contrast-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 15px 0 0; padding: 0; list-style: none; }
.contrast-results li { padding: 9px 11px; border-radius: var(--ui-radius-control); font-weight: 750; }
.contrast-results .is-pass { background: #eaf7ef; color: #17633a; }
.contrast-results .is-fail { background: #fff0ef; color: #a1271d; }
.crop-canvas-wrap { margin-top: 13px; overflow: auto; border-radius: var(--ui-radius-control); background: #eef2f7; text-align: center; touch-action: none; }
.crop-canvas-wrap canvas { display: block; width: auto; max-width: 100%; height: auto; max-height: 70vh; margin: 0 auto; cursor: crosshair; touch-action: none; }
.metadata-warning { min-height: 1.5em; margin: 13px 0 0; color: var(--muted); font-weight: 700; }
.metadata-warning.has-gps { padding: 11px 13px; border: 1px solid #e9b06c; border-radius: var(--ui-radius-control); background: #fff7e8; color: #7b4100; }
.metadata-list { display: grid; grid-template-columns: minmax(120px, .45fr) minmax(0, 1fr); margin: 13px 0 0; border-top: 1px solid var(--border); }
.metadata-list dt,
.metadata-list dd { margin: 0; padding: 9px 10px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.metadata-list dt { color: var(--muted); font-weight: 750; }
.qr-reader-video { display: block; width: min(100%, 680px); margin: 13px auto 0; border-radius: var(--ui-radius-control); background: #111; }
.qr-reader-video[hidden] { display: none; }

@media (max-width: 560px) {
  .contrast-results { grid-template-columns: 1fr; }
  .metadata-list { grid-template-columns: 1fr; }
  .metadata-list dt { padding-bottom: 2px; border-bottom: 0; }
  .metadata-list dd { padding-top: 2px; }
}

/* Homepage catalog stays static. Search results are confined to the dialog. */
.home-category-shortcuts,
.home-featured,
.home-catalog {
  max-width: 1120px;
  margin-inline: auto;
}
.home-category-shortcuts h2,
.home-featured > h2,
.home-catalog > h2 { margin: 0; font-size: clamp(1.25rem, 2.5vw, 1.55rem); }
.home-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 14px; }
.home-search-row input { min-width: 0; }
.home-search-row button { white-space: nowrap; }
.home-search-status { min-height: 1.45em; margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.home-category-shortcuts,
.home-featured,
.home-catalog { margin-top: clamp(30px, 5vw, 48px); }
.home-category-shortcuts > div { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.home-category-shortcuts a {
  padding: 8px 13px;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.home-category-shortcuts a:hover { color: var(--accent-teal); border-color: var(--accent-teal); }
.home-featured > h2::before { content:""; display:inline-block; width:8px; height:8px; margin-inline-end:10px; border-radius:50%; background:var(--recommended-accent); vertical-align:middle; }
.home-featured .tool-grid,
.home-category-grid { margin-top: 16px; }
.home-category { margin-top: 34px; scroll-margin-top: 18px; }
.home-category-heading { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; padding:12px 16px; border-radius:var(--ui-radius-control); background:var(--surface-success); }
.home-category-heading h3 { margin: 0; font-size: 1.2rem; }
.pro-ready-badge { display:inline-block; vertical-align:middle; white-space:nowrap; padding:3px 7px; border-radius:var(--ui-radius-control); background:var(--surface-warm); color:var(--accent-warm); font-size:.75rem; font-weight:700; line-height:1.5; }
.pro-ready-note { font-size:.9rem; }
.home-category-heading span { color: var(--muted); font-size: .9rem; }
.home-category-grid .tool-link-card { gap:14px; padding:16px; box-shadow:0 6px 18px rgb(15 23 42 / .055); }
.home-category-grid .tool-link-card:hover { transform:translateY(-1px); border-color:var(--accent-teal); box-shadow:0 10px 24px rgb(15 23 42 / .1); }
.home-category-grid .tool-icon { flex-basis:44px; width:44px; height:44px; border-radius:12px; font-size:1rem; }
.home-category-grid .tool-link-body h3 { font-size:1.08rem; line-height:1.4; }
.home-category-grid .tool-link-body p { display:block; flex:0 1 auto; line-height:1.5; }
.tool-card-identity { display:flex; flex:0 0 auto; flex-direction:column; align-items:center; gap:6px; }
.tool-card-identity .pro-ready-badge { font-size:.7rem; padding:2px 4px; }
.home-category-grid .tool-open { margin-top:auto; padding-top:12px; }
@media (min-width:1200px) { .home-category-grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media (prefers-reduced-motion:reduce) { .home-category-grid .tool-link-card { transition:none; } }
.home-show-all { display: block; margin: 14px auto 0; }
.home-no-results { margin: 18px 0 0; padding: 16px; border-radius: var(--ui-radius-control); background: #f7f9fc; color: var(--muted); }
.home-tool-card[hidden],
.home-category[hidden],
.home-featured[hidden],
.home-no-results[hidden] { display: none !important; }
.home-category[data-expanded="false"] .home-tool-card { display: none; }
.home-category[data-expanded="false"] .home-tool-card[data-home-desktop-initial] { display: flex; }

.header-controls { display: flex; align-items: center; gap: 10px; }
.header-search-button { display: inline-flex; align-items: center; justify-content: center; }
.header-search-button[hidden] { display: none; }
.home-nowrap { white-space: nowrap; }
.tool-search-dialog { width: calc(100% - 32px); max-width: 660px; max-height: calc(100dvh - 48px); padding: clamp(16px, 3vw, 24px); border: 1px solid var(--border); border-radius: var(--ui-radius-card); color: var(--text); background: var(--surface); box-shadow: var(--shadow); overflow: auto; }
.tool-search-dialog::backdrop { background: rgba(23, 32, 51, .46); }
.search-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-dialog-heading h2 { margin: 0; font-size: 1.3rem; }
.search-dialog-heading button { min-width: 44px; min-height: 44px; font-size: 1.6rem; }
.search-results { display: grid; gap: 8px; }
.search-result { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--border); border-radius: var(--ui-radius-control); text-decoration: none; color: var(--text); overflow-wrap: anywhere; }
.search-result small, .search-result span { color: var(--muted); font-size: .9rem; }
.search-result:hover { background: var(--background); }
.home-guides { margin: var(--ui-section-gap) auto; max-width: 1120px; }
.guide-main { width: min(820px, calc(100% - 32px)); margin: 28px auto 64px; }
.guide-main h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.5; }
.guide-main h2 { margin-top: 1.8em; font-size: 1.3rem; }
.guide-main .tool-link-card h2 { margin-top: 0; }
.guide-main pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px; background: var(--background); border-radius: var(--ui-radius-control); }
.guide-main a, .tool-example a { overflow-wrap: anywhere; }
.guide-main li + li { margin-top: .5em; }
.guide-main .guide-meta { color: var(--muted); font-size: .9rem; }

@media (max-width: 560px) {
  .home-search-row { grid-template-columns: 1fr; }
  .home-search-row button { width: 100%; }
  .home-category[data-expanded="false"] .home-tool-card[data-home-desktop-initial] { display: none; }
  .home-category[data-expanded="false"] .home-tool-card[data-home-mobile-initial] { display: flex; }
}

/* Root language selection */
.language-choice-header { justify-content: center; }
.language-choice-main { width: min(900px, calc(100% - 32px)); margin: 34px auto 64px; }
.language-choice-intro { max-width: 720px; margin: 0 auto; text-align: center; }
.language-choice-intro h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.35rem); line-height: 1.15; letter-spacing: -.04em; }
.language-choice-intro p { margin: 14px 0 0; color: var(--muted); }
.language-choice-nowrap { white-space: nowrap; }
.language-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 34px; }
.language-choice-option { display: flex; min-height: 150px; flex-direction: column; justify-content: center; align-items: center; gap: 8px; color: var(--text); text-align: center; text-decoration: none; }
.language-choice-option strong { color: var(--primary-hover); font-size: 1.65rem; }
.language-choice-option span { color: var(--muted); font-weight: 700; }
.language-choice-option:hover { border-color: #9bb8ef; transform: translateY(-2px); }
.language-choice-option:focus-visible { outline: 3px solid rgba(47, 99, 215, .28); outline-offset: 3px; }
.language-choice-footer { display: grid; gap: 18px; }
.language-choice-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; }
.language-choice-footer nav a { color: var(--muted); font-weight: 700; }

@media (max-width: 560px) {
  .language-choice-header { justify-content: flex-start; }
  .language-choice-main { margin-top: 22px; }
  .language-choice-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 26px; }
  .language-choice-option { min-height: 120px; }
}
