:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --subtle: #8a94a6;
  --line: #dfe4ec;
  --line-strong: #c8d0dc;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --surface-blue: #eef7ff;
  --page: #edf1f6;
  --primary: #121826;
  --accent: #087ccc;
  --accent-dark: #0564a6;
  --danger: #b42318;
  --success: #087a55;
  --focus: #6ab7ff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 12px 30px rgba(16, 24, 40, 0.09);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html {
  scroll-behavior: smooth;
  touch-action: pan-x pan-y;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(8, 124, 204, 0.12), transparent 30rem),
    var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

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

button,
summary,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent-dark);
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid rgba(200, 208, 220, 0.8);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
}

.site-header__inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid #b9decf;
  border-radius: 999px;
  background: #effaf5;
  color: #176b4d;
  font-size: 12px;
  font-weight: 700;
}

.privacy-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #20a16f;
}

.privacy-short {
  display: none;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 46px 0 72px;
}

.hero {
  max-width: 760px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.15;
  letter-spacing: -0.045em;
}

.hero__lead {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 2vw, 14px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.workspace > *,
.search-panel,
.preview-column,
.field-grid > * {
  min-width: 0;
}

.search-panel,
.preview-card {
  border: 1px solid rgba(200, 208, 220, 0.9);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.search-panel {
  overflow: clip;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.preview-card h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.step-list {
  display: flex;
  gap: 6px;
  padding-top: 2px;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line-strong);
}

.step-dot:first-child {
  width: 24px;
  background: var(--accent);
}

.form-section {
  margin: 0;
  padding: 28px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.section-heading h3 {
  margin: 0;
  font-size: 17px;
}

.section-heading p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

.field {
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}

.optional {
  margin-left: 5px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.field input:hover,
.field select:hover {
  border-color: #9ba8b9;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(8, 124, 204, 0.14);
}

.field input::placeholder {
  color: #9aa4b2;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--subtle);
  font-size: 12px;
}

.input-combo {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
}

.keyword-fields.is-muted {
  opacity: 0.48;
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.preset-button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.preset-button:hover,
.preset-button.is-active {
  border-color: #88c9f4;
  background: var(--surface-blue);
  color: var(--accent-dark);
}

.advanced-panel {
  border-bottom: 1px solid var(--line);
}

.advanced-panel > summary {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.advanced-panel > summary::-webkit-details-marker {
  display: none;
}

.advanced-panel > summary::after {
  content: "+";
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--accent-dark);
  font-size: 20px;
}

.advanced-panel[open] > summary::after {
  content: "−";
}

.advanced-summary__text {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-count {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

.filter-count[hidden] {
  display: none;
}

.advanced-content {
  padding: 2px 28px 28px;
}

.advanced-group + .advanced-group {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px dashed var(--line);
}

.advanced-group h4 {
  margin: 0 0 13px;
  font-size: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.toggle-copy strong,
.toggle-copy span {
  display: block;
}

.toggle-copy strong {
  font-size: 13px;
}

.toggle-copy span {
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}

.switch input,
.filter-chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd3df;
  cursor: pointer;
  transition: background 150ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.22);
  transition: transform 150ms ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track,
.filter-chip input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.filter-chip {
  position: relative;
}

.filter-chip span {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: #475467;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: 150ms ease;
}

.filter-chip input:checked + span {
  border-color: #7bc3f2;
  background: var(--surface-blue);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px #7bc3f2;
}

.form-message {
  min-height: 22px;
  margin: 0;
  padding: 0 28px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.form-actions {
  position: sticky;
  z-index: 5;
  bottom: 10px;
  display: grid;
  grid-template-columns: auto auto minmax(190px, 1fr);
  gap: 10px;
  margin: 14px;
  padding: 12px;
  border: 1px solid rgba(200, 208, 220, 0.92);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
  backdrop-filter: blur(14px);
}

.button {
  min-height: 46px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

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

.button:active {
  transform: translateY(0);
}

.button--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 7px 16px rgba(18, 24, 38, 0.2);
}

.button--primary:hover {
  background: #252d3d;
}

.button--secondary {
  border-color: var(--line-strong);
  background: #fff;
  color: #344054;
}

.button--quiet {
  background: var(--surface-soft);
  color: #475467;
}

.button--danger {
  border-color: #f1c0bc;
  background: #fff5f4;
  color: var(--danger);
}

.preview-column {
  position: sticky;
  top: 20px;
}

.preview-card {
  padding: 22px;
}

.preview-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.status-badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.status-badge.is-ready {
  background: #e9f8f1;
  color: var(--success);
}

.preview-summary {
  margin: 0;
  padding: 15px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 4px 11px 11px 4px;
  background: linear-gradient(135deg, #f4faff, #f8fbfe);
  color: #26364d;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.85;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.preview-summary.is-empty {
  border-left-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--subtle);
  font-weight: 500;
}

.query-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #cfe6f6;
  border-radius: 11px;
  background: #f3faff;
}

.query-box__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.copy-button {
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.query-code {
  display: block;
  min-height: 44px;
  overflow-wrap: anywhere;
  color: #1d4766;
  font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.preview-note,
.tips-card {
  color: var(--muted);
  font-size: 12px;
}

.preview-note {
  display: flex;
  gap: 8px;
  margin: 15px 0 0;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.tips-card {
  margin-top: 14px;
  padding: 17px 18px;
  border: 1px solid rgba(200, 208, 220, 0.9);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
}

.tips-card strong {
  display: block;
  margin-bottom: 6px;
  color: #344054;
}

.tips-card p {
  margin: 0;
}

.history-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(16, 24, 40, 0.3);
}

.history-dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: 19px;
}

.dialog-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
}

.history-list {
  max-height: 520px;
  overflow: auto;
  padding: 8px 22px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item__query {
  display: block;
  overflow-wrap: anywhere;
  color: var(--accent-dark);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-decoration: none;
}

.history-item__time {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 11px;
}

.history-delete {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: #fff5f4;
  color: var(--danger);
  font-weight: 900;
  cursor: pointer;
}

.history-empty {
  padding: 56px 18px;
  color: var(--muted);
  text-align: center;
}

.dialog-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  z-index: 1000;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 700;
  transform: translateY(140%);
  opacity: 0;
  transition: 180ms ease;
}

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

.install-prompt {
  position: fixed;
  z-index: 950;
  top: max(76px, calc(env(safe-area-inset-top) + 66px));
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: min(430px, calc(100% - 24px));
  padding: 12px;
  border: 1px solid #c8d9e8;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 36px rgba(16, 24, 40, 0.18);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(12px);
}

.install-prompt[hidden] {
  display: none;
}

.install-prompt.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.install-prompt::before {
  position: absolute;
  top: -7px;
  right: 24px;
  width: 12px;
  height: 12px;
  border-top: 1px solid #c8d9e8;
  border-left: 1px solid #c8d9e8;
  background: #fff;
  content: "";
  transform: rotate(45deg);
}

.install-prompt__icon {
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.install-prompt__copy {
  min-width: 0;
}

.install-prompt__copy strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.install-prompt__copy p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.install-prompt__action {
  min-height: 38px;
  padding: 7px 11px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.install-prompt__close {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.site-footer {
  padding: 26px 16px 42px;
  color: var(--subtle);
  font-size: 12px;
  text-align: center;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

  .preview-column {
    position: static;
  }

  .tips-card {
    display: none;
  }
}

@media (max-width: 640px) {
  .site-header__inner,
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .privacy-pill {
    max-width: 118px;
    justify-content: center;
    text-align: center;
  }

  .privacy-long {
    display: none;
  }

  .privacy-short {
    display: inline;
  }

  .app-shell {
    padding-top: 30px;
  }

  .hero {
    margin-bottom: 20px;
  }

  .panel-header,
  .form-section,
  .advanced-content {
    padding-right: 18px;
    padding-left: 18px;
  }

  .advanced-panel > summary {
    padding-right: 18px;
    padding-left: 18px;
  }

  .step-list {
    display: none;
  }

  .field-grid,
  .field-grid--three,
  .input-combo {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .form-actions .button {
    min-width: 0;
    padding-right: 10px;
    padding-left: 10px;
  }

  .button--primary {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .preview-card {
    padding: 18px;
  }

  .install-prompt {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .install-prompt__action {
    grid-column: 2;
    justify-self: start;
  }

  .install-prompt__close {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .dialog-footer {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
