@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

:root {
  --bg: #eef1f7;
  --surface: rgba(255, 255, 255, 0.86);
  --border: rgba(15, 23, 42, 0.08);
  --ink: #0f172a;
  --muted: #5b6478;
  --accent: #f86c5e;
  --accent-strong: #0f9eb5;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.15);
  --radius: 18px;
  --font-sans: "Zen Kaku Gothic New", "Space Grotesk", "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 120% at 20% 10%, #ffffff 0%, #e3ecff 35%, #eef1f7 70%);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.7;
  position: relative;
  overflow-x: hidden;
}

.bg-decoration {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg-decoration::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.07) 1px, transparent 0);
  background-size: 24px 24px;
  opacity: 0.25;
}

.orb {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
}

.orb-a {
  top: -120px;
  left: -80px;
  background: #fbc2c0;
}

.orb-b {
  right: -140px;
  top: 120px;
  background: #b8d8ff;
}

.orb-c {
  bottom: -160px;
  left: 20%;
  background: #d8f1ff;
}

.hero {
  position: relative;
  padding: 30px clamp(16px, 4vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
  justify-content: center;
  width: min(1100px, calc(100% - 24px));
  margin: 14px auto 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.82));
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 160% at 20% 10%, rgba(248, 108, 94, 0.18), transparent 45%),
              radial-gradient(120% 140% at 90% 40%, rgba(15, 158, 181, 0.2), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 16px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.35), transparent 50%),
              radial-gradient(circle at 70% 70%, rgba(15, 158, 181, 0.08), transparent 55%);
  opacity: 0.9;
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
}

.hero-content h1 {
  margin: 6px 0 10px;
  font-size: clamp(34px, 5.5vw, 46px);
  letter-spacing: -0.02em;
}

.hero-content .lede {
  margin: 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 1.02rem;
}

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

.page {
  padding: 0 clamp(20px, 5vw, 56px) 64px;
  display: grid;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  backdrop-filter: blur(12px);
}

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

.panel-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 700;
  font-family: var(--font-sans);
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #ff8e72 100%);
  color: #fff;
  box-shadow: 0 12px 30px rgba(248, 108, 94, 0.35);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

.btn.subtle {
  background: rgba(15, 158, 181, 0.1);
  color: var(--accent-strong);
  border: none;
}

.eyebrow {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

h2 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3vw, 28px);
}

.hint,
.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.stack {
  display: grid;
}

.gap-lg {
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.2s ease, background 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(15, 158, 181, 0.7);
  box-shadow: 0 10px 24px rgba(15, 158, 181, 0.14);
  background: #fff;
}

select[multiple] {
  min-height: 110px;
  padding: 10px 12px;
}

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

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 28px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 158, 181, 0.25);
  background: rgba(15, 158, 181, 0.08);
  color: var(--ink);
  font-weight: 600;
}

.chip .remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}

.results-panel {
  display: grid;
  gap: 12px;
}

.result-list {
  display: grid;
  gap: 14px;
}

.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.9));
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(15, 158, 181, 0.08), transparent 40%),
              radial-gradient(circle at 80% 10%, rgba(248, 108, 94, 0.1), transparent 45%);
  pointer-events: none;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.result-title {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.05);
  border-radius: 10px;
  color: var(--ink);
  font-weight: 600;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.badge.accent {
  background: rgba(248, 108, 94, 0.1);
  border-color: rgba(248, 108, 94, 0.3);
  color: #c43a21;
}

.badge.secondary {
  background: rgba(15, 158, 181, 0.12);
  border-color: rgba(15, 158, 181, 0.35);
  color: #0f5563;
}

.result-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-card {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
}

.status-card.loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-strong);
  animation: pulse 1.2s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 1; }
}

.details {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  gap: 12px;
}

.content {
  background: rgba(15, 23, 42, 0.025);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.content img {
  max-width: 100%;
  display: block;
  margin: 10px 0;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.content blockquote {
  margin: 10px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--accent-strong);
  background: rgba(15, 158, 181, 0.08);
  border-radius: 10px;
}

.content h1,
.content h2,
.content h3 {
  margin: 18px 0 8px;
}

.content p {
  margin: 10px 0;
}

.content ul,
.content ol {
  padding-left: 20px;
}

.attachments,
.child-pages {
  display: grid;
  gap: 8px;
}

.attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.child-page {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.05);
  background: rgba(15, 158, 181, 0.05);
}

.hidden {
  display: none !important;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

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

.table-wrapper th,
.table-wrapper td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.table-wrapper th {
  background: rgba(15, 158, 181, 0.1);
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast.error {
  background: #c0392b;
}

.workbook-view {
  display: grid;
  gap: 18px;
  margin-top: 8px;
}

.workbook-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.workbook-lead h2 {
  margin: 6px 0 6px;
}

.workbook-meta {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid var(--border);
  width: fit-content;
  font-weight: 700;
  color: var(--ink);
}

.workbook-tags .badge {
  background: rgba(15, 158, 181, 0.12);
  border-color: rgba(15, 158, 181, 0.24);
}

.question-list {
  display: grid;
  gap: 14px;
}

.question-card {
  position: relative;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.88));
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.question-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 18% 20%, rgba(15, 158, 181, 0.12), transparent 45%),
              radial-gradient(circle at 82% 10%, rgba(248, 108, 94, 0.12), transparent 55%);
  pointer-events: none;
}

.workbook-images {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.workbook-images figure {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
}

.workbook-images img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.workbook-files {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}

.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.file-pill:hover {
  background: rgba(15, 158, 181, 0.12);
  border-color: rgba(15, 158, 181, 0.2);
}

.diagram-block {
  position: relative;
  z-index: 1;
  margin: 10px 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid var(--border);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre-wrap;
  overflow-x: auto;
}

.diagram-block.mermaid {
  background: linear-gradient(135deg, rgba(188, 224, 255, 0.25), rgba(255, 220, 220, 0.2));
  font-family: inherit;
}

.question-head {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.question-number {
  min-width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(15, 158, 181, 0.12);
  color: #0f5563;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.question-text {
  margin: 4px 0 0;
  font-weight: 700;
}

.answer {
  display: none;
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.03);
}

.answer.open {
  display: grid;
  gap: 8px;
  animation: fadeIn 0.2s ease;
}

.answer-label {
  margin: 0;
  font-weight: 700;
  color: var(--muted);
}

.answer-body {
  margin: 0;
  color: var(--ink);
}

.answer-toggle {
  position: relative;
  z-index: 1;
  margin-top: 10px;
}

.workbook-card .result-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.workbook-card .result-title::after {
  content: "Workbook";
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
  font-weight: 700;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--ink);
  font-weight: 700;
  width: fit-content;
}

.pill.accent {
  background: rgba(248, 108, 94, 0.12);
  color: #c43a21;
}

.pill.subtle {
  background: rgba(15, 158, 181, 0.16);
  color: #0f5563;
}

.divider {
  height: 1px;
  background: var(--border);
}

.inline-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  font-weight: 600;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

pre {
  padding: 12px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 10px;
  overflow-x: auto;
}

@media (max-width: 960px) {
  .hero {
    width: min(980px, calc(100% - 20px));
    gap: 16px;
  }
}

@media (max-width: 720px) {
  .panel,
  .hero {
    padding: 18px 14px 16px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .hero {
    gap: 12px;
    margin: 12px auto 8px;
    border-radius: 18px;
    align-items: center;
  }

  .hero-content {
    text-align: center;
    align-items: center;
  }

  .hero-content h1 {
    font-size: clamp(28px, 8vw, 34px);
    margin-bottom: 6px;
  }

  .hero-content .lede {
    font-size: 0.98rem;
  }

  .hero-actions {
    justify-content: center;
  }

}
