/* Name Pronunciation Note Builder — Styles */

:root {
  --bg: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #334155;
  --bg-input: #1e293b;
  --border: #475569;
  --border-focus: #6366f1;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-bg: rgba(99, 102, 241, 0.12);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --max-width: 1280px;
  --transition: 0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 16px; }

a { color: var(--accent-hover); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

/* Header */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.logo:hover, .logo:focus-visible { text-decoration: none; }

.site-nav {
  display: flex;
  gap: 4px;
}
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover, .nav-link:focus-visible {
  background: var(--accent-bg);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  background: var(--accent);
  color: #fff;
}

/* Layout */
.layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  flex: 1;
}
.layout-builder {
  display: contents;
}
.layout-library {
  display: contents;
}

/* Sections */
.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.section-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

/* Form */
.builder-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}
.required { color: var(--danger); }
.form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  padding: 10px 14px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.form-input::placeholder { color: var(--text-dim); }
.form-textarea { resize: vertical; min-height: 60px; }
.form-hint { font-size: 0.8rem; color: var(--text-dim); }

/* Preset chips */
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.chip:hover, .chip:focus-visible {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--text);
  outline: none;
}
.chip:active { transform: scale(0.97); }

/* Buttons */
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  font-family: var(--font);
  gap: 6px;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-card); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* Card Preview */
.preview-section {
  position: sticky;
  top: 80px;
  align-self: start;
}
.card-preview {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-preview-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-name {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.card-phonetic {
  font-size: 1.15rem;
  color: var(--accent-hover);
  font-weight: 500;
  font-style: italic;
}
.card-syllables {
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  word-spacing: 6px;
}
.card-syllables .stressed {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: var(--warning);
}
.card-hint {
  font-size: 0.92rem;
  color: var(--success);
  font-weight: 500;
}
.card-note {
  font-size: 0.88rem;
  color: var(--text-muted);
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.card-origin {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.card-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.preview-note {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* Library */
.library-section {
  grid-column: 1 / -1;
}
.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.library-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.library-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.library-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}
.library-empty svg { margin-bottom: 12px; }
.library-count {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 12px;
}

/* Library card */
.lib-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
}
.lib-card:hover { border-color: var(--accent); }
.lib-card-name { font-size: 1.2rem; font-weight: 700; }
.lib-card-phonetic { font-size: 0.95rem; color: var(--accent-hover); font-style: italic; }
.lib-card-syllables { font-size: 0.85rem; color: var(--text-muted); }
.lib-card-hint { font-size: 0.85rem; color: var(--success); }
.lib-card-note { font-size: 0.82rem; color: var(--text-dim); }
.lib-card-origin { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.lib-card-actions { display: flex; gap: 6px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Examples */
.examples-section { grid-column: 1 / -1; }
.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.example-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: all var(--transition);
}
.example-card:hover, .example-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-bg);
  outline: none;
}
.ex-name { font-weight: 700; font-size: 1rem; }
.ex-phonetic { font-size: 0.85rem; color: var(--accent-hover); font-style: italic; }
.ex-tag { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }

/* Guide */
.guide-section { grid-column: 1 / -1; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.guide-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.guide-block h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--accent-hover);
}
.guide-block p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* FAQ */
.faq-section { grid-column: 1 / -1; }
.faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.faq-item summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-size: 1.3rem;
  color: var(--text-dim);
  transition: transform var(--transition);
}
.faq-item[open] summary::after { content: '−'; }
.faq-item summary:hover { background: var(--accent-bg); }
.faq-item p {
  padding: 0 20px 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 9999;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast[hidden] { display: none; }

/* Footer */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  margin-top: 48px;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.footer-text { font-size: 0.88rem; color: var(--text-muted); }
.footer-nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-nav a { font-size: 0.85rem; }
.footer-meta { font-size: 0.78rem; color: var(--text-dim); }

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

/* Responsive */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 20px 16px;
    gap: 24px;
  }
  .preview-section { position: static; }
  .card-preview { padding: 24px; }
  .card-name { font-size: 1.5rem; }
  .form-row { grid-template-columns: 1fr; }
  .library-list { grid-template-columns: 1fr; }
  .header-inner { padding: 0 16px; }
  .site-nav { gap: 2px; }
  .nav-link { padding: 5px 10px; font-size: 0.82rem; }
  .library-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .site-nav { width: 100%; justify-content: space-between; }
  .examples-grid { grid-template-columns: 1fr 1fr; }
  .guide-grid { grid-template-columns: 1fr; }
}

/* Print styles */
@media print {
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .builder-section, .library-section, .examples-section, .guide-section, .faq-section, .form-actions, .library-actions, .card-preview-actions, .preview-note, .toast, .skip-link { display: none !important; }
  .preview-section { position: static; }
  .card-preview { box-shadow: none; border: 2px solid #000; page-break-inside: avoid; }
  .card-name, .card-phonetic, .card-syllables, .card-hint, .card-note, .card-origin { color: #000; }
}

/* Print all cards mode */
body.print-all .site-header,
body.print-all .site-footer,
body.print-all .builder-section,
body.print-all .examples-section,
body.print-all .guide-section,
body.print-all .faq-section,
body.print-all .preview-section,
body.print-all .library-header,
body.print-all .library-count,
body.print-all .lib-card-actions,
body.print-all .toast,
body.print-all .skip-link,
body.print-all #library-empty { display: none !important; }

body.print-all .library-section { display: block !important; }
body.print-all .library-list {
  display: block;
}
body.print-all .lib-card {
  border: 1px solid #000;
  background: #fff;
  color: #000;
  page-break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 0;
}
body.print-all .lib-card-name,
body.print-all .lib-card-phonetic,
body.print-all .lib-card-syllables,
body.print-all .lib-card-hint,
body.print-all .lib-card-note,
body.print-all .lib-card-origin { color: #000; }
body.print-all .lib-card-phonetic { font-style: italic; }
body.print-all { background: #fff; color: #000; }
body.print-all main { max-width: 100%; padding: 0; }



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
