@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=DM+Mono:wght@400;500&display=swap");

:root {
  color-scheme: light;
  --page-bg: #edf7f2;
  --page-bg-deep: #e2efe8;
  --surface: rgba(255, 255, 255, 0.82);
  --line: rgba(104, 136, 121, 0.18);
  --line-strong: rgba(75, 119, 93, 0.28);
  --ink: #162033;
  --muted: #6f7b96;
  --accent: #2f9b67;
  --accent-strong: #257a51;
  --danger: #c44d77;
  --focus: #25c3d8;
  --shadow: 0 28px 60px rgba(25, 35, 66, 0.12);
  --shadow-soft: 0 14px 34px rgba(25, 35, 66, 0.08);
  --radius-xl: 26px;
  --font-sans: "DM Sans", "Aptos", "Segoe UI", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(47, 155, 103, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(73, 181, 138, 0.1), transparent 22%),
    linear-gradient(180deg, #f7f9ff 0%, var(--page-bg) 52%, var(--page-bg-deep) 100%);
  font-family: var(--font-sans);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1, h2, h3, h4, p { margin: 0; }

.wrap { max-width: 1220px; margin: 0 auto; padding: 24px; }
.shell { min-height: calc(100vh - 48px); display: flex; flex-direction: column; gap: 18px; }
.surface {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  background: linear-gradient(135deg, #43b37c 0%, #2f9b67 52%, #7ed3a8 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 16px 30px rgba(47, 155, 103, 0.24);
}
.brand-copy h1 { margin-bottom: 4px; font-size: 24px; line-height: 1.05; }
.brand-copy p { color: var(--muted); font-size: 14px; }
.topbar-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(47, 155, 103, 0.12));
  border: 1px solid rgba(47, 155, 103, 0.18);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.hero { padding: 18px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) 320px; gap: 18px; align-items: stretch; }
.hero-card, .card {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}
.hero-card { padding: 22px; }
.kicker, .card-label, .workspace-kicker {
  display: inline-block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hero-card h2 { margin: 10px 0 12px; font-size: 38px; line-height: 1.02; letter-spacing: -0.06em; }
.hero-card p { color: var(--muted); font-size: 15px; line-height: 1.65; max-width: 58ch; }
.mini-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.mini-card { padding: 13px 14px; border-radius: 18px; background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.85); box-shadow: var(--shadow-soft); }
.mini-card strong { display: block; margin-bottom: 4px; font-size: 14px; }
.mini-card span { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
.hero-pro-tip {
  margin-top: 20px;
  padding: 20px 22px;
  min-height: 112px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(47, 155, 103, 0.18);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(47, 155, 103, 0.08));
  color: var(--accent-strong);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
}
.hero-sheet {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(47,155,103,.08));
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: var(--shadow-soft);
}
.hero-sheet-header { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.sheet-chip, .preview-meta span {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(47,155,103,.12));
  color: var(--accent-strong);
  border: 1px solid rgba(47,155,103,.16);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sheet-chip { padding: 8px 10px; }
.sudoku-mini {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  background: #fff;
}
.sudoku-mini span {
  display: grid;
  place-items: center;
  border: 1px solid rgba(22,32,51,.28);
  font-weight: 700;
}
.sudoku-mini span:nth-child(3n) { border-right-width: 2px; }
.sudoku-mini span:nth-child(n+19):nth-child(-n+27),
.sudoku-mini span:nth-child(n+46):nth-child(-n+54) { border-bottom-width: 2px; }
.app-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.sidebar { display: flex; flex-direction: column; gap: 18px; }
.card { padding: 18px; }
.section-heading { margin-bottom: 16px; }
.section-heading strong { display: block; margin-top: 5px; font-size: 20px; line-height: 1.15; }
.field { display: grid; gap: 7px; margin-bottom: 13px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  padding: 12px;
}
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.checkbox-row {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.action-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.primary-button, .secondary-button {
  min-height: 44px;
  border-radius: 16px;
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 13px;
}
.primary-button { border-color: transparent; color: #fff; background: linear-gradient(135deg, #43b37c 0%, #2f9b67 100%); box-shadow: 0 16px 26px rgba(47,155,103,.18); }
.secondary-button { color: var(--muted); background: rgba(255,255,255,.88); }
.primary-button:disabled, .secondary-button:disabled { opacity: .45; cursor: wait; }
.helper-text, .tips-copy { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.status-message { min-height: 18px; margin-top: 10px; color: var(--accent-strong); font-size: 12px; font-family: var(--font-mono); line-height: 1.4; }
.status-message.error { color: var(--danger); }
.tips-card h3 { margin: 8px 0 0; font-size: 18px; }
.guide-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.guide-card {
  padding: 24px;
}
.guide-card h3 {
  margin: 8px 0 12px;
  font-size: 24px;
  line-height: 1.15;
}
.guide-copy,
.guide-list {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}
.guide-copy {
  margin-top: 12px;
}
.guide-list {
  margin: 12px 0 0;
  padding-left: 22px;
}
.guide-list li + li {
  margin-top: 8px;
}
.preview-panel { padding: 18px; }
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.workspace-title-wrap strong { display: block; margin-top: 5px; font-size: 22px; line-height: 1.1; }
.preview-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.preview-meta span { padding: 8px 10px; }
.worksheet-preview {
  overflow: auto;
  min-height: 660px;
  border-radius: 22px;
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(255,255,255,.86);
  padding: 18px;
}
.worksheet-frame {
  width: min(100%, 760px);
  min-height: 620px;
  margin: 0 auto;
  padding: 30px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(25,35,66,.12);
}
.empty-state { display: grid; place-items: center; color: var(--muted); font-family: var(--font-mono); font-size: 13px; text-align: center; }
.preview-page-title { margin: 0 0 20px; text-align: center; font-size: 24px; }
.preview-puzzle-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.preview-puzzle { break-inside: avoid; }
.puzzle-title { margin-bottom: 8px; text-align: center; font-size: 14px; font-weight: 700; }
.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1;
  border: 2px solid #111;
  background: #fff;
}
.sudoku-cell {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-left: 1px solid #777;
  border-top: 1px solid #777;
  font-size: clamp(12px, 2vw, 18px);
  font-weight: 700;
}
.sudoku-cell:nth-child(9n+1) { border-left: 0; }
.sudoku-cell:nth-child(-n+9) { border-top: 0; }
.sudoku-cell:nth-child(9n+4),
.sudoku-cell:nth-child(9n+7) { border-left: 2px solid #111; }
.sudoku-cell:nth-child(n+28):nth-child(-n+36),
.sudoku-cell:nth-child(n+55):nth-child(-n+63) { border-top: 2px solid #111; }
.page-number { margin-top: 18px; text-align: center; color: #555; font-size: 12px; }

@media (max-width: 980px) {
  .hero-grid, .app-grid { grid-template-columns: 1fr; }
  .preview-panel { min-height: auto; }
}
@media (max-width: 720px) {
  .wrap { padding: 14px; }
  .topbar { padding: 16px; align-items: flex-start; flex-direction: column; }
  .hero-card h2 { font-size: 30px; }
  .mini-features, .two-column, .action-row { grid-template-columns: 1fr; }
  .preview-header { align-items: flex-start; flex-direction: column; }
}
