:root {
  --primary: #345ca8;
  --on-primary: #ffffff;
  --primary-container: #d8e2ff;
  --on-primary-container: #001a43;
  --secondary: #58616f;
  --secondary-container: #dce2f0;
  --surface: #ffffff;
  --surface-container-low: #ffffff;
  --surface-container: #f0f1f8;
  --surface-container-high: #e8eaf1;
  --panel-bg: #ffffff;
  --field-bg: #f0f1f8;
  --code-bg: #f8f9ff;
  --nested-bg: rgba(255, 255, 255, 0.72);
  --toast-bg: #263143;
  --toast-text: #ffffff;
  --outline: #74777f;
  --outline-variant: #c4c6d0;
  --on-surface: #191b20;
  --on-surface-variant: #44474f;
  --success: #226c42;
  --warning: #8d5d00;
  --error: #ba1a1a;
  --shadow: 0 18px 50px rgba(31, 42, 68, 0.13);
  font-family: "Roboto", "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --primary: #9fbeff;
  --on-primary: #092f66;
  --primary-container: #274b86;
  --on-primary-container: #d8e2ff;
  --secondary: #bdc7d8;
  --secondary-container: #3f4654;
  --surface: #111318;
  --surface-container-low: #191b20;
  --surface-container: #20232a;
  --surface-container-high: #2a2d35;
  --panel-bg: #191b20;
  --field-bg: #20232a;
  --code-bg: #111318;
  --nested-bg: rgba(255, 255, 255, 0.05);
  --toast-bg: #e2e2e9;
  --toast-text: #191b20;
  --outline: #8e9199;
  --outline-variant: #44474f;
  --on-surface: #e2e2e9;
  --on-surface-variant: #c4c6d0;
  --success: #85d99d;
  --warning: #ffcc70;
  --error: #ffb4ab;
  --shadow: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--on-surface);
  background: var(--surface);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.material-symbols-rounded {
  font-size: 1.25rem;
  line-height: 1;
}

.shell {
  width: clamp(320px, 90vw, 960px);
  margin: 0 auto;
  padding: 22px 0 48px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  margin-bottom: 14px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--outline-variant);
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-container);
}

.eyebrow,
.label {
  margin: 0;
  color: var(--secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  margin-bottom: 6px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 100%;
  font-size: clamp(1.42rem, 2.45vw, 2.35rem);
  line-height: 1.08;
  word-break: keep-all;
  overflow-wrap: normal;
}

h2 {
  font-size: 1.45rem;
  line-height: 1.18;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 18px;
  min-width: 0;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(116, 119, 127, 0.2);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.control-panel,
.lookup-panel {
  padding: 22px;
}

.output-panel {
  display: flex;
  padding: 22px;
  flex-direction: column;
}

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

.field-group {
  display: grid;
  gap: 9px;
}

label {
  color: var(--on-surface-variant);
  font-size: 0.92rem;
  font-weight: 700;
}

.input-row {
  display: flex;
  align-items: start;
  gap: 12px;
  min-height: 50px;
  padding: 9px 14px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--field-bg);
  transition: border-color 160ms ease, background 160ms ease;
  min-width: 0;
}

.input-row:focus-within {
  border-color: var(--primary);
  background: var(--surface-container-low);
}

.input-icon {
  margin-top: 3px;
}

.input-row textarea {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  max-height: 160px;
  resize: none;
  overflow-y: hidden;
  border: 0;
  outline: 0;
  color: var(--on-surface);
  background: transparent;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.35;
}

.segmented span {
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid var(--outline-variant);
  border-radius: 999px;
  color: var(--on-surface-variant);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
}

.actions,
.resolver-row,
.bind-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.bind-actions {
  align-items: center;
  justify-content: end;
}

.actions {
  margin-top: 12px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button {
  padding: 0 18px;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.filled {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(52, 92, 168, 0.24);
}

.tonal {
  color: var(--on-primary-container);
  background: var(--primary-container);
}

.icon-button {
  width: 44px;
  color: var(--primary);
  background: var(--primary-container);
}

.code-box {
  width: 100%;
  max-width: 100%;
  min-height: 92px;
  max-height: 180px;
  margin: 0;
  overflow-x: auto;
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  color: var(--on-surface);
  background: var(--code-bg);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre;
}

.segmented {
  position: relative;
}

.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented input:checked + span {
  border-color: transparent;
  color: var(--on-primary-container);
  background: var(--primary-container);
}

.result-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  min-width: 0;
}

.result-card,
.domain-result {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-container);
}

.result-card.ok,
.domain-result.ok {
  border-left: 5px solid var(--success);
}

.result-card.warn,
.domain-result.warn {
  border-left: 5px solid var(--warning);
}

.result-card.error,
.domain-result.error {
  border-left: 5px solid var(--error);
}

.domain-result.missing {
  border-left: 5px solid var(--error);
}

.result-title {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.result-content {
  min-width: 0;
  overflow-x: auto;
  color: var(--on-surface-variant);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
}

.domain-result {
  gap: 14px;
  padding: 18px;
}

.domain-title {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.domain-title h3 {
  margin: 0;
  min-width: 0;
  font-size: 1.22rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.service-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.service-status {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: var(--nested-bg);
}

.service-status.ok {
  border: 1px solid rgba(34, 108, 66, 0.34);
}

.service-status.warn {
  border: 1px solid rgba(141, 93, 0, 0.34);
}

.service-status.missing {
  border: 1px solid rgba(186, 26, 26, 0.34);
}

.service-title {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.service-state-text {
  color: var(--on-surface);
  font-weight: 700;
}

.service-value,
.domain-error {
  min-width: 0;
  overflow-x: auto;
  color: var(--on-surface-variant);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

.dns-details {
  min-width: 0;
  border-radius: 8px;
  background: var(--nested-bg);
}

.dns-details summary {
  min-height: 44px;
  padding: 12px 14px;
  color: var(--on-surface);
  font-weight: 700;
  cursor: pointer;
}

.dns-answer {
  display: grid;
  min-width: 0;
  gap: 6px;
  padding: 0 14px 14px;
}

.dns-answer + .dns-answer {
  padding-top: 12px;
  border-top: 1px solid var(--outline-variant);
}

.dns-answer strong {
  color: var(--secondary);
}

.dns-answer code {
  display: block;
  min-width: 0;
  overflow-x: auto;
  color: var(--on-surface-variant);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
}

.dns-answer.empty {
  color: var(--on-surface-variant);
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 13px 16px;
  border-radius: 8px;
  color: var(--toast-text);
  background: var(--toast-bg);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

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

@media (max-width: 900px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
    align-items: start;
  }

}

@media (max-width: 560px) {
  .shell {
    width: calc(100% - 20px);
    padding-top: 16px;
  }

  .control-panel,
  .lookup-panel,
  .output-panel {
    padding: 16px;
  }

  .actions .button {
    flex: 1 1 130px;
  }

  .panel-header {
    align-items: start;
  }

  .lookup-actions {
    justify-content: start;
    width: 100%;
  }

  .bind-actions {
    justify-content: start;
    width: 100%;
  }

  h1 {
    font-size: clamp(1.25rem, 7vw, 1.8rem);
  }

  .service-list {
    grid-template-columns: 1fr;
  }
}
