:root {
  --ihu-navy: #001e60;
  --ihu-red: #9d2235;
  --ihu-gray: #63666a;
  --ihu-silver: #9a9c9f;
  --navy: var(--ihu-navy);
  --ink: #202735;
  --muted: var(--ihu-gray);
  --line: #dcdfe3;
  --paper: #f6f7f9;
  --white: #fff;
  --teal: var(--ihu-red);
  --teal-soft: #f7eaed;
  --amber: #c58a2d;
  --amber-soft: #fbf2df;
  --blue: #294c8b;
  --blue-soft: #e9eef7;
  --shadow: 0 16px 38px rgba(0, 30, 96, .09);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: "DM Sans", system-ui, sans-serif; font-size: 15px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.home-shell { min-height: 100vh; display: grid; grid-template: 68px 1fr / 228px 1fr; }
.home-header { grid-column: 1 / -1; position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 250px minmax(300px, 560px) 1fr; align-items: center; gap: 22px; padding: 0 22px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.home-brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; width: max-content; }
.ihu-brand-mark { flex: 0 0 auto; width: 28px; height: 41px; background: var(--ihu-red); -webkit-mask: url("assets/ihu-mark.png") center / contain no-repeat; mask: url("assets/ihu-mark.png") center / contain no-repeat; }
.brand-divider { flex: 0 0 auto; width: 1px; height: 34px; margin: 0 2px; background: #d2d6dc; }
.product-lockup { display: block; min-width: 0; }
.home-brand strong { display: block; color: var(--navy); font-family: "Newsreader", serif; font-size: 20px; line-height: 18px; letter-spacing: -.25px; }
.home-brand strong span { color: var(--ihu-red); }
.home-brand small { display: block; margin-top: 4px; color: var(--ihu-gray); font-size: 10px; line-height: 1; letter-spacing: 1.3px; font-weight: 700; white-space: nowrap; }
.global-search { height: 38px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: #f7f8f7; border-radius: 10px; padding: 0 11px; color: var(--muted); }
.global-search:focus-within { border-color: #c9929b; box-shadow: 0 0 0 3px rgba(157,34,53,.08); background: #fff; }
.global-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 13px; color: var(--ink); }
.global-search kbd { border: 1px solid #d6dcde; border-radius: 5px; padding: 2px 5px; background: #fff; color: #74828c; font-size: 10px; }
.header-tools { display: flex; justify-content: flex-end; align-items: center; gap: 9px; }
.workspace-chip { display: flex; align-items: center; gap: 6px; padding: 7px 9px; background: #f4f7f6; border: 1px solid var(--line); border-radius: 8px; color: #5e6c76; font-size: 11px; font-weight: 600; }
.workspace-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.round-button, .avatar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.avatar { border: 0; color: #fff; background: var(--navy); font-size: 10px; font-weight: 700; }
.home-sidebar { grid-row: 2; position: sticky; top: 68px; height: calc(100vh - 68px); display: flex; flex-direction: column; padding: 18px 13px 14px; background: #fff; border-right: 1px solid var(--line); }
.create-button { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; padding: 12px; border: 0; border-radius: 8px; background: var(--teal); color: #fff; box-shadow: 0 6px 14px rgba(157,34,53,.18); font-size: 12px; font-weight: 700; }
.create-button:hover { background: #821c2c; transform: translateY(-1px); }
.create-button span { font-size: 16px; font-weight: 400; }
.home-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 24px; }
.home-nav p { margin: 0 10px 7px; color: #7f8b93; font-size: 10px; letter-spacing: 1.3px; font-weight: 700; }
.home-nav button { display: grid; grid-template-columns: 21px 1fr auto; align-items: center; gap: 7px; width: 100%; padding: 10px; border: 0; border-radius: 7px; background: transparent; color: #5c6a73; text-align: left; font-size: 12px; }
.home-nav button:hover { background: #f5f7f6; color: var(--ink); }
.home-nav button.active { background: var(--teal-soft); color: var(--ihu-red); font-weight: 700; }
.home-nav button > span { font-size: 14px; text-align: center; }
.home-nav button b { min-width: 20px; padding: 2px 5px; border-radius: 8px; background: #edf0f1; color: #68777f; text-align: center; font-size: 10px; }
.home-nav button.active b { background: #ead1d6; color: var(--teal); }
.sidebar-guide { margin-top: auto; padding: 13px; border: 1px solid #ead1d6; border-radius: 10px; background: linear-gradient(145deg, #fcf6f7, #fff); }
.guide-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--teal-soft); color: var(--teal); }
.sidebar-guide strong { display: block; margin-top: 9px; font-family: "Newsreader", serif; color: var(--navy); font-size: 14px; }
.sidebar-guide p { margin: 5px 0 9px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.sidebar-guide button { border: 0; padding: 0; background: transparent; color: var(--teal); font-size: 11px; font-weight: 700; }
.sidebar-footer { padding: 14px 8px 0; }
.sidebar-footer span, .sidebar-footer small { display: block; }
.sidebar-footer span { color: #65747d; font-size: 11px; font-weight: 700; }
.sidebar-footer small { margin-top: 2px; color: #7f8b92; font-size: 10px; }
.home-main { grid-column: 2; min-width: 0; padding: 34px clamp(26px, 4vw, 60px) 70px; overflow: hidden; }
.welcome-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; max-width: 1240px; margin: 0 auto 24px; }
.eyebrow { margin: 0 0 6px; color: #6f7e88; font-size: 11px; letter-spacing: 1.5px; font-weight: 700; }
.welcome-row h1 { margin: 0 0 5px; font-family: "Newsreader", serif; color: var(--navy); font-size: clamp(32px, 4vw, 46px); line-height: 1; }
.welcome-row > div > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.rag-health { display: flex; align-items: center; gap: 9px; min-width: 180px; padding: 9px 11px; border: 1px solid #d8e5e1; border-radius: 9px; background: #f5faf8; }
.rag-health > span { width: 8px; height: 8px; border-radius: 50%; background: #4caf79; box-shadow: 0 0 0 4px #e1f2e8; }
.rag-health.offline > span { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.rag-health strong, .rag-health small { display: block; }
.rag-health strong { font-size: 12px; }
.rag-health small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.quick-start { max-width: 1240px; min-height: 230px; margin: 0 auto 30px; display: grid; grid-template-columns: 1.1fr .9fr; overflow: hidden; border-radius: 16px; background: var(--navy); box-shadow: var(--shadow); color: #fff; position: relative; }
.quick-start[hidden] { display: none; }
.quick-start::after { content: ""; position: absolute; width: 280px; height: 280px; right: -100px; top: -130px; border-radius: 50%; border: 1px solid rgba(255,255,255,.08); box-shadow: 0 0 0 40px rgba(255,255,255,.025), 0 0 0 80px rgba(255,255,255,.02); }
.quick-copy { padding: 30px 34px; position: relative; z-index: 1; }
.quick-kicker { color: #f0a7b3; font-size: 11px; letter-spacing: 1.5px; font-weight: 700; }
.quick-copy h2 { margin: 9px 0; font-family: "Newsreader", serif; font-size: clamp(26px, 3vw, 36px); line-height: 1.05; }
.quick-copy p { max-width: 560px; margin: 0 0 18px; color: #c8d3d9; font-size: 13px; line-height: 1.6; }
.quick-copy button { border: 0; border-radius: 7px; padding: 10px 13px; background: #fff; color: var(--navy); font-size: 12px; font-weight: 700; }
.quick-copy button span { margin-left: 8px; color: var(--teal); }
.flow-preview { align-self: center; margin: 24px 34px 24px 8px; padding: 8px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(255,255,255,.06); position: relative; z-index: 1; }
.flow-preview > div { display: grid; grid-template-columns: 33px 1fr 22px; align-items: center; gap: 9px; padding: 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.flow-preview > div:last-child { border: 0; }
.flow-preview b { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.09); color: #f0a7b3; font-family: "Newsreader", serif; }
.flow-preview strong, .flow-preview small { display: block; }
.flow-preview strong { font-size: 12px; }
.flow-preview small { margin-top: 2px; color: #bdcbd2; font-size: 10px; }
.flow-preview i { color: #f0a7b3; font-style: normal; }
.projects-section { max-width: 1240px; margin: 0 auto; }
.section-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 13px; }
.section-toolbar h2 { display: inline; margin: 0 7px 0 0; font-family: "Newsreader", serif; color: var(--navy); font-size: 21px; }
.section-toolbar > div > span { color: #77858d; font-size: 11px; }
.toolbar-actions, .toolbar-actions label, .view-switch { display: flex; align-items: center; }
.toolbar-actions { gap: 9px; }
.toolbar-actions label { gap: 5px; color: var(--muted); font-size: 11px; }
.toolbar-actions select { border: 1px solid var(--line); border-radius: 7px; padding: 7px 25px 7px 9px; background: #fff; color: var(--ink); font-size: 11px; outline: 0; }
.view-switch { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; }
.view-switch button { width: 29px; height: 28px; border: 0; background: #fff; color: #88949b; }
.view-switch button.active { background: var(--navy); color: #fff; }
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.project-grid.list { grid-template-columns: 1fr; }
.project-card { position: relative; min-width: 0; min-height: 214px; display: flex; flex-direction: column; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: inherit; text-decoration: none; box-shadow: 0 3px 12px rgba(27,45,56,.025); transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.project-card:hover { transform: translateY(-2px); border-color: #b7bdc8; box-shadow: 0 10px 24px rgba(0,30,96,.08); }
.project-grid.list .project-card { min-height: 118px; display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 15px; }
.project-top { display: flex; justify-content: space-between; align-items: flex-start; }
.project-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 11px; color: var(--teal); background: var(--teal-soft); font-family: "Newsreader", serif; font-size: 20px; }
.project-icon.amber { color: var(--amber); background: var(--amber-soft); }
.project-icon.blue { color: var(--blue); background: var(--blue-soft); }
.project-icon.purple { color: #7e6187; background: #f0e9f2; }
.project-more { border: 0; background: transparent; color: #9ca5aa; letter-spacing: 1px; }
.project-copy { margin-top: 17px; }
.project-copy h3 { margin: 0 0 6px; color: var(--navy); font-family: "Newsreader", serif; font-size: 18px; line-height: 1.15; }
.project-copy p { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin: 0; min-height: 38px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.project-grid.list .project-top { display: contents; }
.project-grid.list .project-icon { grid-column: 1; grid-row: 1; }
.project-grid.list .project-more { position: absolute; right: 14px; top: 14px; }
.project-grid.list .project-copy { grid-column: 2; grid-row: 1; margin: 0; }
.project-grid.list .project-meta { grid-column: 3; grid-row: 1; border: 0; padding: 0 28px 0 0; min-width: 220px; }
.project-badges { display: flex; gap: 5px; margin-top: 12px; }
.project-badges span { padding: 4px 7px; border-radius: 10px; background: #f1f4f4; color: #65747d; font-size: 10px; font-weight: 700; }
.project-badges .active-badge { color: var(--teal); background: var(--teal-soft); }
.project-meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 13px; border-top: 1px solid #edf0f1; color: #74828b; font-size: 11px; }
.project-meta span { display: flex; align-items: center; gap: 4px; }
.empty-projects { grid-column: 1 / -1; padding: 50px 20px; border: 1px dashed #cbd5d8; border-radius: 12px; text-align: center; color: var(--muted); }
.empty-projects strong { display: block; color: var(--navy); font-family: "Newsreader", serif; font-size: 20px; }
.empty-projects span { display: block; margin-top: 6px; font-size: 13px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(11,27,42,.5); backdrop-filter: blur(3px); }
.modal-backdrop[hidden] { display: none; }
.project-modal { width: min(470px, 100%); position: relative; padding: 28px; border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.modal-close { position: absolute; right: 13px; top: 13px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: #f1f3f3; color: var(--muted); font-size: 20px; }
.modal-symbol { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 13px; border-radius: 12px; color: var(--teal); background: var(--teal-soft); font-size: 21px; }
.project-modal h2 { margin: 0 0 7px; font-family: "Newsreader", serif; color: var(--navy); font-size: 27px; }
.project-modal > p:not(.eyebrow) { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.project-modal label { display: block; margin-top: 12px; color: #64727a; font-size: 12px; font-weight: 700; }
.project-modal input, .project-modal select { width: 100%; margin-top: 5px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--ink); background: #fff; font-size: 13px; }
.project-modal input:focus, .project-modal select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(157,34,53,.08); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.cancel-button, .submit-button { padding: 10px 14px; border-radius: 7px; font-size: 12px; font-weight: 700; }
.cancel-button { border: 1px solid var(--line); background: #fff; color: var(--muted); }
.submit-button { border: 0; background: var(--teal); color: #fff; }
.home-toast { position: fixed; z-index: 80; left: 50%; bottom: -60px; transform: translateX(-50%); padding: 10px 16px; border-radius: 8px; background: var(--navy); color: #fff; box-shadow: var(--shadow); font-size: 13px; transition: bottom .2s ease; }
.home-toast.show { bottom: 24px; }
@media (max-width: 1060px) {
  .home-header { grid-template-columns: 225px 1fr auto; }
  .workspace-chip { display: none; }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .home-shell { display: block; }
  .home-header { position: sticky; height: 62px; grid-template-columns: 1fr auto; padding: 0 14px; }
  .global-search { display: none; }
  .home-sidebar { position: static; height: auto; padding: 10px 13px; border-right: 0; border-bottom: 1px solid var(--line); }
  .home-nav { flex-direction: row; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; }
  .home-nav p, .home-nav button span, .home-nav button b, .sidebar-guide, .sidebar-footer { display: none; }
  .home-nav button { display: block; width: auto; white-space: nowrap; }
  .home-main { padding: 24px 15px 50px; }
  .welcome-row { align-items: flex-start; }
  .rag-health { display: none; }
  .quick-start { grid-template-columns: 1fr; }
  .flow-preview { margin: 0 20px 20px; }
  .project-grid { grid-template-columns: 1fr; }
  .section-toolbar { align-items: flex-start; }
  .toolbar-actions label { display: none; }
}
@media (max-width: 460px) {
  .quick-copy { padding: 25px 22px; }
  .welcome-row h1 { font-size: 34px; }
  .section-toolbar h2 { display: block; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; } }

/* Theme control */
.theme-control { position: relative; }
.theme-toggle { display: grid; place-items: center; font-size: 17px; line-height: 1; }
.theme-menu { position: absolute; z-index: 80; top: calc(100% + 9px); right: 0; width: 236px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
.theme-menu[hidden] { display: none; }
.theme-menu > p { margin: 4px 8px 6px; color: var(--muted); font-size: 10px; letter-spacing: 1.35px; font-weight: 800; }
.theme-option { width: 100%; display: grid; grid-template-columns: 28px 1fr 18px; align-items: center; gap: 9px; padding: 9px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; }
.theme-option:hover { background: var(--paper); }
.theme-option > span:first-child { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; color: var(--ihu-red); background: var(--teal-soft); font-size: 15px; }
.theme-option strong, .theme-option small { display: block; }
.theme-option strong { font-size: 12px; }
.theme-option small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.theme-option b { visibility: hidden; color: var(--ihu-red); }
.theme-option.active { background: var(--teal-soft); }
.theme-option.active b { visibility: visible; }

/* Dark theme */
html[data-theme="dark"] {
  --ink: #edf2f8;
  --muted: #aeb7c4;
  --line: #354258;
  --paper: #0e1623;
  --white: #182334;
  --teal: #f0a7b3;
  --teal-soft: #3b202a;
  --amber: #e8b55b;
  --amber-soft: #3b2d18;
  --blue: #84b3e1;
  --blue-soft: #1c2f50;
  --shadow: 0 18px 42px rgba(0, 0, 0, .28);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--paper); }
html[data-theme="dark"] :is(h1, h2, h3, h4, .welcome-row h1, .section-toolbar h2, .project-copy h3, .empty-projects strong, .project-modal h2, .home-brand strong) { color: var(--ink); }
html[data-theme="dark"] .home-brand strong span { color: #d86a7a; }
html[data-theme="dark"] :is(.create-button, .submit-button) { color: #fff; background: var(--ihu-red); }
html[data-theme="dark"] :is(.create-button, .submit-button):hover { background: #b32a42; }
html[data-theme="dark"] .brand-divider { background: #46536a; }
html[data-theme="dark"] .home-header { background: rgba(24, 35, 52, .96); }
html[data-theme="dark"] .home-sidebar { background: #182334; }
html[data-theme="dark"] :is(.global-search, .workspace-chip, .round-button, .toolbar-actions select, .view-switch, .view-switch button, .project-card, .project-modal, .project-modal input, .project-modal select, .cancel-button) { color: var(--ink); background: #121d2c; border-color: var(--line); }
html[data-theme="dark"] .home-nav button { color: #b9c2ce; }
html[data-theme="dark"] .home-nav button:hover { color: var(--ink); background: #223044; }
html[data-theme="dark"] .home-nav button.active { color: #f0a7b3; background: var(--teal-soft); }
html[data-theme="dark"] .home-nav button b { color: #b5bfcb; background: #263247; }
html[data-theme="dark"] .home-nav button.active b { color: #f0a7b3; background: #512733; }
html[data-theme="dark"] .sidebar-guide { border-color: #51313a; background: linear-gradient(145deg, #2a1d25, #182334); }
html[data-theme="dark"] .sidebar-guide strong { color: var(--ink); }
html[data-theme="dark"] .rag-health { border-color: #31554c; background: #172b2a; }
html[data-theme="dark"] .project-card:hover { border-color: #5a687d; box-shadow: 0 12px 26px rgba(0,0,0,.22); }
html[data-theme="dark"] .project-badges span { color: #c3ccd8; background: #263247; }
html[data-theme="dark"] .project-meta { border-color: var(--line); color: #aeb7c4; }
html[data-theme="dark"] .project-icon.purple { color: #c7a5d0; background: #392b43; }
html[data-theme="dark"] .modal-close { background: #263247; }
html[data-theme="dark"] .quick-start { box-shadow: 0 18px 42px rgba(0,0,0,.3); }
html[data-theme="dark"] .theme-menu { background: #1b2738; }
html[data-theme="dark"] .theme-option:hover { background: #243247; }
html[data-theme="dark"] .theme-option.active { background: var(--teal-soft); }
html[data-theme="dark"] ::placeholder { color: #7e8999; }

@media (max-width: 760px) {
  .theme-menu { right: -42px; }
}
