@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);
  --surface-strong: #ffffff;
  --line: rgba(104, 136, 121, 0.18);
  --line-strong: rgba(75, 119, 93, 0.28);
  --ink: #162033;
  --muted: #6f7b96;
  --accent: #2f9b67;
  --accent-strong: #257a51;
  --accent-soft: rgba(47, 155, 103, 0.1);
  --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;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-sans: "DM Sans", "Aptos", "Segoe UI", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
  --grid-border: rgba(22, 32, 51, 0.78);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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,
textarea,
select {
  font: inherit;
}

button,
.secondary-button,
.primary-button,
.hero-sheet,
.mini-card,
.card,
.word-pill,
.preview-meta span {
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea: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, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.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, 0.96), rgba(47, 155, 103, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.sheet-chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-strong);
  border: 1px solid rgba(47, 155, 103, 0.16);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.hero-sheet-preview {
  flex: 1;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(104, 136, 121, 0.12);
  padding: 18px;
  display: grid;
  gap: 16px;
}

.preview-dots {
  display: flex;
  gap: 8px;
}

.preview-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(47, 155, 103, 0.28);
}

.preview-lines {
  display: grid;
  gap: 8px;
}

.preview-lines span {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(47, 155, 103, 0.14), rgba(111, 123, 150, 0.12));
}

.preview-lines span:nth-child(1) {
  width: 64%;
}

.preview-lines span:nth-child(2) {
  width: 88%;
}

.preview-lines span:nth-child(3) {
  width: 74%;
}

.preview-lines span:nth-child(4) {
  width: 82%;
}

.preview-grid-mini {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.preview-grid-mini span {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: rgba(47, 155, 103, 0.12);
  border: 1px solid rgba(47, 155, 103, 0.16);
}

.app-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  flex: 1;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.card {
  padding: 18px;
}

.section-heading strong,
.workspace-title-wrap strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.controls-panel form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

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

.field span,
.field legend {
  color: var(--ink);
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(47, 155, 103, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  padding: 12px 14px;
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 180px;
}

fieldset {
  border: 1px solid rgba(47, 155, 103, 0.12);
  border-radius: 20px;
  padding: 14px 16px 16px;
  margin: 0;
  background: rgba(255, 255, 255, 0.52);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-top: 8px;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.checkbox-grid input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.two-column,
.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

button {
  border: none;
  border-radius: 16px;
  padding: 13px 16px;
  font-weight: 700;
}

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

.primary-button {
  background: linear-gradient(135deg, #43b37c 0%, #2f9b67 100%);
  color: #fff;
  box-shadow: 0 20px 30px rgba(47, 155, 103, 0.24);
}

.primary-button:hover:not(:disabled) {
  box-shadow: 0 24px 34px rgba(47, 155, 103, 0.28);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.helper-text,
.status-message,
.tips-copy {
  color: var(--muted);
}

.helper-text {
  margin: -4px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.status-message {
  min-height: 1.5em;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}

.tips-card h3 {
  margin: 2px 0 10px;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.tips-card h4 {
  margin: 16px 0 10px;
  font-size: 15px;
}

.tips-copy {
  line-height: 1.5;
  font-size: 14px;
}

.tips-copy + .tips-copy {
  margin-top: 10px;
}

.tips-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.55;
  font-size: 14px;
}

.tips-list li + li {
  margin-top: 8px;
}

.workspace {
  min-width: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.preview-meta span {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(47, 155, 103, 0.12));
  color: var(--accent-strong);
  padding: 8px 12px;
  border: 1px solid rgba(47, 155, 103, 0.16);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.worksheet-preview {
  padding: 16px;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(233, 248, 240, 0.92)),
    repeating-linear-gradient(45deg, rgba(104, 136, 121, 0.04) 0 18px, rgba(104, 136, 121, 0.06) 18px 36px);
}

.worksheet-frame {
  background: var(--surface-strong);
  border-radius: 20px;
  padding: 26px;
  box-shadow: inset 0 0 0 1px rgba(104, 136, 121, 0.08);
}

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

.worksheet-heading h3 {
  font-size: clamp(1.5rem, 2vw, 2.2rem);
  letter-spacing: -0.04em;
}

.grid-container {
  display: grid;
  justify-content: center;
  margin-bottom: 22px;
}

.grid-container.empty-state {
  min-height: 420px;
  place-items: center;
  border: 1.5px dashed rgba(47, 155, 103, 0.22);
  border-radius: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
  padding: 24px;
}

.word-search-grid {
  display: grid;
  gap: 0;
  border: 2px solid var(--grid-border);
  width: fit-content;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.grid-cell {
  width: var(--cell-size, 34px);
  height: var(--cell-size, 34px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(22, 32, 51, 0.2);
  border-bottom: 1px solid rgba(22, 32, 51, 0.2);
  font-family: var(--font-mono);
  font-size: calc(var(--cell-size, 34px) * 0.42);
  font-weight: 500;
  text-transform: uppercase;
  color: var(--ink);
}

.word-bank h4 {
  margin-bottom: 12px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.word-bank-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.word-pill {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(47, 155, 103, 0.1);
  color: var(--accent-strong);
  border: 1px solid rgba(47, 155, 103, 0.14);
  font-weight: 700;
  font-size: 13px;
}

.maze-preview-grid {
  display: grid;
  gap: 18px;
  justify-items: center;
  align-items: center;
  width: 100%;
}

.maze-preview-grid.maze-count-1 {
  grid-template-columns: 1fr;
}

.maze-preview-grid.maze-count-2,
.maze-preview-grid.maze-count-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.maze-preview-grid.maze-count-2.maze-stack-vertical {
  grid-template-columns: 1fr;
}

.maze-preview-grid canvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

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

  .preview-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .wrap {
    padding: 14px;
  }

  .shell {
    min-height: calc(100vh - 28px);
  }

  .topbar {
    padding: 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-card h2 {
    font-size: 30px;
  }

  .mini-features,
  .two-column,
  .action-row,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .preview-header,
  .worksheet-heading {
    flex-direction: column;
  }

  .workspace,
  .hero,
  .card {
    padding: 16px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .wrap {
    max-width: none;
    padding: 0;
  }

  .shell {
    min-height: auto;
  }

  .topbar,
  .hero,
  .controls-panel,
  .tips-card,
  .preview-header {
    display: none;
  }

  .app-grid {
    display: block;
  }

  .workspace,
  .worksheet-preview,
  .worksheet-frame {
    box-shadow: none;
    border: none;
    padding: 0;
    background: #fff;
  }
}
