:root {
  --blue: #004aad;
  --blue-dark: #00317a;
  --blue-light: #eaf2ff;
  --cyan: #00aee8;
  --ink: #101a27;
  --muted: #64748b;
  --line: #dfe7f1;
  --surface: #ffffff;
  --background: #f4f7fb;
  --green: #16a36a;
  --shadow: 0 14px 38px rgba(31, 57, 90, .09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background: var(--background);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 290px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #071b37;
  color: white;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.brand { color: white; text-decoration: none; display: flex; align-items: center; gap: 11px; margin: 0 7px 27px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(135deg, var(--cyan), var(--blue)); font: 800 1.2rem "Open Sans"; }
.brand strong, .brand small { display: block; }
.brand strong { font: 800 1rem "Open Sans"; }
.brand small { color: #9eb4d1; margin-top: 2px; }
.eyebrow { color: var(--blue); text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; font-weight: 700; }
.project-summary { border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); border-radius: 14px; padding: 15px; margin-bottom: 18px; }
.project-summary .eyebrow { color: #8eb8ec; }
.project-summary strong { display: block; font-size: .92rem; margin: 6px 0 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-summary small { color: #9eb4d1; }
.project-summary #sidebarCategory { display: block; margin: -5px 0 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-track { height: 6px; border-radius: 20px; background: rgba(255,255,255,.12); overflow: hidden; margin-bottom: 8px; }
.progress-track span { height: 100%; display: block; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), #63e6be); transition: width .35s ease; }
.module-nav { display: grid; gap: 5px; }
.nav-item { border: 0; background: transparent; color: #aabbd2; border-radius: 10px; padding: 10px; text-align: left; display: grid; grid-template-columns: 28px 1fr 18px; align-items: center; gap: 8px; font-size: .82rem; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: #0d356a; color: white; }
.nav-number { width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,.09); font-size: .73rem; font-weight: 700; }
.nav-item.active .nav-number { background: var(--cyan); color: #05213e; }
.nav-check { color: #54d6a0; font-weight: 700; }
.sidebar-action { margin-top: auto; border: 1px solid rgba(255,255,255,.17); color: white; background: rgba(255,255,255,.06); border-radius: 11px; padding: 12px; font-weight: 600; }
.sidebar-action:hover { background: rgba(255,255,255,.12); }
.reset-project-action { margin-top: 8px; color: #ffd1d1; }

.main-content { padding: 0 42px 30px; min-width: 0; }
.topbar { height: 88px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); margin-bottom: 27px; }
.topbar h1 { font: 800 clamp(1.25rem, 2vw, 1.65rem) "Open Sans"; margin: 3px 0 0; }
.save-state { margin-left: auto; color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: 7px; }
.save-state span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.save-state.saving span { background: #f59e0b; }
.account-box { margin-left: auto; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .78rem; }
.account-box button { border: 1px solid var(--line); background: white; color: var(--blue); padding: 6px 9px; border-radius: 8px; font-weight: 700; }
.account-box + .save-state { margin-left: 0; }
.menu-button { display: none; background: white; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.welcome-card { max-width: 1050px; margin: 0 auto 22px; padding: 24px 28px; color: white; border-radius: 18px; background: linear-gradient(125deg, #07336c, #0057bd 67%, #00aee8); box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; gap: 30px; overflow: hidden; position: relative; }
.welcome-card::after { content: ""; position: absolute; width: 180px; height: 180px; right: -65px; top: -95px; border: 28px solid rgba(255,255,255,.08); border-radius: 50%; }
.badge { display: inline-block; padding: 4px 9px; border-radius: 30px; background: rgba(255,255,255,.15); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.welcome-card h2 { font: 800 clamp(1.25rem, 2.6vw, 1.85rem) "Open Sans"; margin: 9px 0 6px; }
.welcome-card p { max-width: 680px; color: #dceaff; margin: 0; font-size: .9rem; }
.welcome-stat { min-width: 112px; text-align: center; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.12); z-index: 1; }
.welcome-stat strong, .welcome-stat span { display: block; }
.welcome-stat strong { font: 800 1.65rem "Open Sans"; }
.welcome-stat span { color: #dceaff; font-size: .72rem; }
.prompt-library-card { max-width: 1050px; margin: 0 auto 22px; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 17px; padding: 19px 22px; border: 1px solid #cbdcf1; border-radius: 16px; background: linear-gradient(135deg, #ffffff, #f5f9ff); box-shadow: 0 10px 28px rgba(31, 57, 90, .06); }
.prompt-library-card-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; color: white; background: linear-gradient(135deg, var(--blue), var(--cyan)); font-size: 1.45rem; }
.prompt-library-card h2 { font: 800 1.05rem "Open Sans"; margin: 0 0 4px; }
.prompt-library-card p { max-width: 740px; margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.prompt-library-open { white-space: nowrap; }

.workspace { max-width: 1050px; margin: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.module-header { padding: 28px 30px 23px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 52px 1fr; gap: 16px; align-items: start; }
.module-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.45rem; background: var(--blue-light); }
.module-header h2 { font: 800 1.35rem "Open Sans"; margin: 1px 0 7px; }
.module-header p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; padding: 28px 30px 32px; }
.field { display: grid; align-content: start; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 700; font-size: .86rem; }
.field-hint { color: var(--muted); font-size: .77rem; line-height: 1.45; }
.field input, .field textarea, .field select { width: 100%; color: var(--ink); background: #fbfcfe; border: 1px solid #cfd9e6; border-radius: 10px; padding: 12px 13px; outline: none; transition: .2s; }
.field textarea { min-height: 105px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { background: white; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,74,173,.09); }
.required { color: #d83939; }
.context-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; padding: 17px; border: 1px solid #c9dcf5; border-radius: 13px; background: #f7fbff; }
.context-panel strong { color: #073d7e; font: 800 .9rem "Open Sans"; }
.context-panel p { margin: 5px 0 0; color: #486581; font-size: .82rem; line-height: 1.55; }
.reference-case { padding-left: 17px; border-left: 1px solid #c9dcf5; color: #304b66; font-size: .79rem; line-height: 1.5; }
.reference-case span { display: block; margin-bottom: 4px; color: var(--blue); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.tip { grid-column: 1 / -1; border-left: 4px solid var(--cyan); background: #eefaff; padding: 13px 15px; border-radius: 0 10px 10px 0; color: #345269; font-size: .82rem; line-height: 1.5; }
.tip strong { color: #123a5a; }
.ai-coach { grid-column: 1 / -1; border: 1px solid #b8d7ff; background: linear-gradient(135deg, #f3f8ff, #f1fcff); border-radius: 14px; padding: 17px; }
.ai-coach-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ai-coach h3 { font: 800 .95rem "Open Sans"; margin: 0 0 4px; color: #073d7e; }
.ai-coach p { margin: 0; color: #55708e; font-size: .8rem; }
.ai-response { display: none; white-space: pre-wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid #cce0f7; color: #173b5e; font-size: .84rem; line-height: 1.6; }
.ai-response.visible { display: block; }
.workspace-footer { max-width: 1050px; margin: 18px auto 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.workspace-footer > span { color: var(--muted); font-size: .8rem; }
.button { border-radius: 10px; padding: 11px 17px; font-weight: 700; font-size: .86rem; border: 1px solid transparent; }
.button.primary { background: var(--blue); color: white; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: var(--blue); background: white; border-color: #bfd0e6; }
.button.danger { color: white; background: #c92a2a; border-color: #c92a2a; }
.button.danger:hover { background: #a61e1e; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.summary-view { padding: 30px; }
.summary-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 20px; }
.summary-heading h2 { font: 800 1.45rem "Open Sans"; margin: 4px 0; }
.summary-heading p { color: var(--muted); margin: 0; }
.summary-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.summary-section { break-inside: avoid; border: 1px solid var(--line); border-radius: 13px; padding: 18px; margin-bottom: 12px; }
.summary-section h3 { font: 800 1rem "Open Sans"; color: var(--blue); margin: 0 0 13px; }
.summary-context { margin-bottom: 15px; padding: 12px; border-radius: 9px; background: #f3f8ff; color: #365571; }
.summary-context strong { color: var(--blue); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.summary-context p { margin: 4px 0; font-size: .8rem; line-height: 1.45; }
.summary-context small { color: var(--muted); line-height: 1.4; }
.answer { margin-bottom: 12px; }
.answer:last-child { margin-bottom: 0; }
.answer strong { display: block; font-size: .76rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; margin-bottom: 3px; }
.answer p { margin: 0; line-height: 1.55; white-space: pre-wrap; }
.empty-answer { color: #94a3b8; font-style: italic; }
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(3, 15, 32, .74); overflow-y: auto; }
.modal-panel { width: min(1120px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; background: white; border-radius: 20px; padding: 30px; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.modal-panel h2 { font: 800 clamp(1.4rem, 3vw, 2rem) "Open Sans"; margin: 10px 0 7px; }
.modal-intro { margin: 0 0 24px; color: var(--muted); }
.modal-badge { color: white; background: var(--blue); }
.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.category-card { display: flex; flex-direction: column; align-items: flex-start; min-height: 270px; padding: 21px; border: 1px solid var(--line); border-radius: 16px; background: #fbfdff; transition: transform .2s, border-color .2s, box-shadow .2s; }
.category-card:hover { transform: translateY(-2px); border-color: #9cc5f7; box-shadow: var(--shadow); }
.category-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; background: var(--blue-light); font-size: 1.45rem; }
.category-card h3 { font: 800 1rem "Open Sans"; margin: 14px 0 6px; }
.category-card p { color: var(--muted); font-size: .8rem; line-height: 1.5; margin: 0 0 10px; }
.category-types { color: #38516d; font-size: .76rem; line-height: 1.5; margin-bottom: 17px; }
.category-card .button { width: 100%; margin-top: auto; }
.modal-note { color: var(--muted); font-size: .76rem; line-height: 1.5; margin: 18px 0 0; }
.confirmation-panel { width: min(510px, 100%); text-align: center; }
.confirmation-panel h2 { font-size: 1.45rem; }
.confirmation-panel p { color: var(--muted); line-height: 1.55; }
.warning-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto; border-radius: 50%; color: #a61e1e; background: #fff0f0; font: 800 1.5rem "Open Sans"; }
.warning-copy { padding: 12px; border-radius: 10px; background: #fff5f5; color: #7d2525 !important; font-weight: 600; }
.modal-actions { display: flex; justify-content: center; gap: 10px; margin-top: 21px; }
.prompt-library-modal-panel { width: min(820px, 100%); }
.prompt-library-modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.prompt-library-modal-head h2 { margin-bottom: 5px; }
.prompt-library-modal-head p { margin: 0; color: var(--muted); font-size: .84rem; }
.prompt-library-category { display: inline-block; margin-top: 9px; color: var(--blue); font-size: .78rem; font-weight: 700; }
.modal-close { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: #50647c; background: white; font-size: 1.5rem; line-height: 1; }
.modal-close:hover { color: var(--blue); background: var(--blue-light); }
.prompt-library-status { padding-top: 16px; color: var(--muted); font-size: .82rem; }
.prompt-accordion { display: grid; gap: 9px; margin-top: 16px; }
.prompt-stage { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.prompt-stage-toggle { width: 100%; display: grid; grid-template-columns: 32px 1fr auto 20px; align-items: center; gap: 10px; padding: 14px 16px; border: 0; color: var(--ink); background: white; text-align: left; }
.prompt-stage-toggle:hover { background: #f8fbff; }
.prompt-stage-number { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--blue); background: var(--blue-light); font-size: .75rem; font-weight: 800; }
.prompt-stage-title { font-weight: 700; font-size: .87rem; }
.prompt-stage-count { color: var(--muted); font-size: .72rem; }
.prompt-stage-chevron { color: var(--blue); font-size: 1rem; transition: transform .2s; }
.prompt-stage-toggle[aria-expanded="true"] .prompt-stage-chevron { transform: rotate(180deg); }
.prompt-stage-content { padding: 0 16px 16px 58px; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.prompt-empty { margin: 0; padding: 13px; border-radius: 9px; background: #f6f8fb; font-style: italic; }
.prompt-item { margin-bottom: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.prompt-item:last-child { margin-bottom: 0; }
.prompt-item h4 { margin: 0 0 5px; font: 800 .88rem "Open Sans"; }
.prompt-item p { margin: 0 0 9px; color: var(--muted); font-size: .78rem; }
.prompt-how-to { margin: 10px 0; padding: 11px; border-left: 3px solid var(--cyan); border-radius: 0 8px 8px 0; background: #eefaff; color: #365571; font-size: .77rem; line-height: 1.5; }
.prompt-how-to strong, .prompt-variables > strong { display: block; margin-bottom: 4px; color: #123a5a; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.prompt-variables { margin: 10px 0; padding: 11px; border-radius: 9px; background: #fffaf0; }
.prompt-variable { display: grid; grid-template-columns: minmax(145px, auto) 1fr; gap: 9px; align-items: start; padding: 7px 0; border-bottom: 1px solid #f2e7cc; color: #5d4b25; font-size: .75rem; line-height: 1.4; }
.prompt-variable:last-child { border-bottom: 0; }
.prompt-variable code { color: #7a4f00; font-weight: 800; overflow-wrap: anywhere; }
.prompt-variable small { display: block; margin-top: 2px; color: #806f4d; }
.prompt-ready-label { display: block; margin: 12px 0 5px; color: var(--blue); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.prompt-item pre { margin: 0 0 10px; padding: 11px; overflow-x: auto; border-radius: 8px; background: #eef4fb; white-space: pre-wrap; font: 400 .77rem/1.5 "DM Sans", sans-serif; }
.prompt-item .button { padding: 8px 11px; font-size: .76rem; }
.summary-category { display: inline-flex; align-items: center; gap: 6px; margin-top: 7px; color: var(--blue); font-size: .82rem; font-weight: 700; }
.toast { position: fixed; right: 22px; bottom: 22px; background: #10243e; color: white; border-radius: 10px; padding: 11px 16px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .25s; box-shadow: var(--shadow); font-size: .84rem; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; width: 290px; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 10px 0 35px rgba(0,0,0,.25); }
  .main-content { padding: 0 18px 25px; }
  .menu-button { display: block; }
  .topbar { height: 76px; }
  .account-box span, .save-state { display: none; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .main-content { padding: 0 12px 22px; }
  .welcome-card { padding: 20px; align-items: flex-start; }
  .welcome-stat { display: none; }
  .prompt-library-card { grid-template-columns: 44px 1fr; padding: 17px; }
  .prompt-library-card-icon { width: 44px; height: 44px; }
  .prompt-library-open { grid-column: 1 / -1; width: 100%; }
  .module-header { padding: 22px 18px; grid-template-columns: 44px 1fr; gap: 12px; }
  .module-icon { width: 44px; height: 44px; }
  .form-grid { grid-template-columns: 1fr; padding: 22px 18px 25px; }
  .field.full { grid-column: auto; }
  .context-panel { grid-column: auto; grid-template-columns: 1fr; }
  .reference-case { padding: 14px 0 0; border-left: 0; border-top: 1px solid #c9dcf5; }
  .tip { grid-column: auto; }
  .ai-coach { grid-column: auto; }
  .ai-coach-head { align-items: flex-start; flex-direction: column; }
  .workspace-footer > span { display: none; }
  .summary-heading { display: block; }
  .summary-actions { margin-top: 15px; }
  .modal-overlay { padding: 10px; align-items: start; }
  .modal-panel { max-height: none; padding: 22px 17px; border-radius: 16px; }
  .category-grid { grid-template-columns: 1fr; }
  .category-card { min-height: 0; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
  .prompt-stage-toggle { grid-template-columns: 30px 1fr 18px; padding: 13px 12px; }
  .prompt-stage-count { display: none; }
  .prompt-stage-content { padding: 0 12px 13px; }
  .prompt-variable { grid-template-columns: 1fr; gap: 3px; }
}
@media print {
  .sidebar, .topbar, .welcome-card, .prompt-library-card, .workspace-footer, .summary-actions { display: none !important; }
  .app-shell { display: block; }
  .main-content { padding: 0; }
  .workspace { border: 0; box-shadow: none; }
  .summary-view { padding: 0; }
}
