:root {
  --ink: #183230;
  --ink-soft: #31514d;
  --paper: #f5f1e9;
  --paper-strong: #fffdfa;
  --clay: #e76f51;
  --gold: #e9b44c;
  --moss: #49796b;
  --moss-dark: #2d5a50;
  --fog: #dce6e1;
  --line: rgba(24, 50, 48, .16);
  --muted: #5f6d68;
  --shadow: 0 14px 40px rgba(18, 43, 40, .10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, select, input, textarea { min-height: 42px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
a { color: inherit; }
img { max-width: 100%; display: block; }

.skip-link { position: fixed; left: 12px; top: -48px; z-index: 100; background: var(--ink); color: white; padding: 10px 14px; border-radius: 8px; transition: top .18s ease-out; }
.skip-link:focus { top: 12px; }

.site-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255, 253, 250, .95); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar-inner, .page-width { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 70px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: -.035em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--ink); border-radius: 12px; color: var(--gold); font-size: 15px; letter-spacing: -.1em; }
.brand-title { font-size: 1.05rem; }
.brand-subtitle { display: block; color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 11px; padding: 9px 14px; text-decoration: none; font-weight: 720; font-size: .87rem; transition: transform .16s ease-out, box-shadow .16s ease-out, background .16s ease-out; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(24, 50, 48, .13); }
.button:active:not(:disabled) { transform: scale(.98); }
.button-primary { color: #fff; background: var(--moss-dark); }
.button-secondary { color: var(--ink); background: var(--paper-strong); border-color: var(--line); }
.button-quiet { color: var(--ink-soft); background: transparent; border-color: transparent; }
.button-danger { color: #b53b29; background: #fff2ef; border-color: #f2c2b9; }
.icon-button { width: 42px; padding: 0; }

.hero { position: relative; min-height: 390px; overflow: hidden; background: var(--ink); color: #fff; }
.hero-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .45; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(16, 42, 39, .94), rgba(16, 42, 39, .62) 58%, rgba(16, 42, 39, .3)); }
.hero-content { position: relative; z-index: 1; width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 74px 0 58px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; color: #f6d37f; font-size: .78rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 21px; height: 2px; background: currentColor; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 720px; margin-bottom: 12px; font-size: clamp(2.35rem, 6vw, 4.4rem); line-height: .98; letter-spacing: -.065em; }
.hero-copy { max-width: 620px; margin-bottom: 26px; color: rgba(255,255,255,.88); font-size: clamp(1rem, 2vw, 1.16rem); line-height: 1.55; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; max-width: 690px; }
.hero-stat { flex: 1 1 130px; padding: 13px 15px; border: 1px solid rgba(255,255,255,.28); border-radius: 15px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.hero-stat strong { display: block; font-size: 1.6rem; letter-spacing: -.03em; }
.hero-stat span { color: rgba(255,255,255,.78); font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.field-label { display: block; margin-bottom: 6px; font-size: .73rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
select, input, textarea { width: 100%; padding: 10px 11px; color: var(--ink); background: var(--paper-strong); border: 1px solid var(--line); border-radius: 10px; outline: none; }
select:focus, input:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(233, 180, 76, .6); outline-offset: 2px; }
textarea { min-height: 100px; resize: vertical; }

.sample-banner { display: flex; align-items: center; gap: 9px; padding: 10px 12px; margin: 22px 0 0; color: #754518; background: #fff5d9; border: 1px solid #ead29a; border-radius: 10px; font-size: .88rem; }
.sample-banner strong { color: #603110; }
.section { padding: 56px 0; }
.section-soft { background: #edf2ed; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-title { margin: 0; font-size: clamp(1.65rem, 3vw, 2.5rem); letter-spacing: -.045em; }
.section-copy { max-width: 620px; margin: 7px 0 0; color: var(--muted); line-height: 1.55; }

.type-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.type-tab { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; color: var(--ink-soft); background: var(--paper-strong); font-size: .84rem; font-weight: 700; }
.type-tab.is-active { color: white; background: var(--ink); border-color: var(--ink); }
.filter-row { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin: 20px 0; }
.search-wrap { position: relative; }
.search-wrap span { position: absolute; left: 13px; top: 11px; color: var(--muted); }
.search-wrap input { padding-left: 39px; }

.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.content-card { display: flex; flex-direction: column; min-height: 226px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-strong); box-shadow: 0 3px 0 rgba(24, 50, 48, .02); }
.card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-height: 23px; margin-bottom: 12px; color: var(--moss-dark); font-size: .73rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.badge { padding: 4px 7px; color: #34544d; background: #e0ece5; border-radius: 999px; font-size: .67rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.badge-sample { color: #80531b; background: #fff0cb; }
.status-pill { padding: 4px 9px; border-radius: 999px; font-size: .67rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.status-old { color: #5c6560; background: #e4e7e4; }
.status-current { color: #fff; background: var(--moss-dark); }
.status-future { color: #7a4a08; background: #ffe6b3; }
.content-card h3 { margin-bottom: 9px; font-size: 1.15rem; line-height: 1.16; letter-spacing: -.025em; }
.content-card p { color: var(--muted); font-size: .92rem; line-height: 1.5; }
.card-details { margin-top: auto; padding-top: 14px; color: var(--ink-soft); font-size: .8rem; line-height: 1.45; }
.card-link { margin-top: 13px; padding: 0; justify-content: flex-start; color: var(--moss-dark); background: none; font-size: .84rem; }
.empty-state { grid-column: 1 / -1; padding: 48px 22px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); background: rgba(255,255,255,.45); }

.guide-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr); gap: 24px; }
.guide-panel, .chat-panel, .admin-panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-strong); box-shadow: var(--shadow); }
.guide-mark { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 13px; border-radius: 15px; color: #fff; background: var(--clay); font-size: 1.45rem; }
.guide-panel h2 { margin-bottom: 8px; font-size: 1.8rem; letter-spacing: -.045em; }
.guide-panel p { color: var(--muted); line-height: 1.55; }
.prompt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 20px; }
.prompt-button { min-height: 58px; padding: 10px; text-align: left; color: var(--ink); background: #f2f6f2; border: 1px solid #d8e4db; border-radius: 12px; font-weight: 700; font-size: .85rem; }
.prompt-button:hover { background: #e4eee7; }
.chat-panel { display: flex; flex-direction: column; min-height: 380px; }
.chat-history { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: 330px; padding: 2px 2px 12px; }
.message { max-width: 92%; padding: 11px 12px; border-radius: 13px; line-height: 1.45; font-size: .9rem; white-space: pre-wrap; }
.message-user { align-self: end; color: #fff; background: var(--ink); border-bottom-right-radius: 3px; }
.message-guide { align-self: start; background: #edf3ef; border-bottom-left-radius: 3px; }
.message-guide strong { color: var(--moss-dark); }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; border-top: 1px solid var(--line); padding-top: 14px; }
.chat-form input { min-width: 0; }
.match-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.match-chip { border: 0; padding: 5px 8px; color: var(--moss-dark); background: #dcebe1; border-radius: 8px; font-size: .73rem; font-weight: 750; text-align: left; }

.footer { padding: 32px 0 42px; color: #b7cac2; background: var(--ink); }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.footer p { margin: 0; font-size: .82rem; }
.footer .button { color: #fff; border-color: rgba(255,255,255,.3); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(11, 27, 26, .55); }
.modal { width: min(760px, 100%); max-height: min(88vh, 880px); overflow: auto; padding: 24px; border-radius: 20px; background: var(--paper); box-shadow: 0 26px 75px rgba(0,0,0,.28); }
.modal-wide { width: min(1020px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 20px; }
.modal-head h2 { margin: 0; font-size: 1.65rem; letter-spacing: -.045em; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.detail-block { padding: 13px; background: var(--paper-strong); border: 1px solid var(--line); border-radius: 11px; }
.detail-block small { display: block; margin-bottom: 5px; color: var(--muted); font-size: .69rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-block p { margin: 0; line-height: 1.48; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.tag { padding: 4px 7px; color: var(--ink-soft); background: #e7eee9; border-radius: 999px; font-size: .72rem; font-weight: 700; }

.detail-section { margin-top: 22px; }
.detail-section h4 { margin: 0 0 10px; font-size: .95rem; letter-spacing: -.01em; }
.relationship-list { display: flex; flex-wrap: wrap; gap: 8px; }
.relationship-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; background: #eef4ef; border: 1px solid var(--line); border-radius: 10px; font-size: .82rem; }
.relationship-chip small { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 600; }
.timeline-list { display: flex; flex-direction: column; gap: 10px; border-left: 2px solid var(--line); padding-left: 14px; }
.timeline-item { position: relative; }
.timeline-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--moss-dark); }
.timeline-date { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.timeline-item strong { display: block; margin: 2px 0; }
.timeline-item p { margin: 0; color: var(--muted); font-size: .87rem; line-height: 1.45; }
.artifact-list { display: flex; flex-direction: column; gap: 8px; }
.artifact-row { padding: 10px 12px; background: var(--paper-strong); border: 1px solid var(--line); border-radius: 10px; }
.artifact-row strong { display: block; }
.artifact-row small { color: var(--muted); }

.admin-shell { min-height: 100vh; padding: 40px 0; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 22px; }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.admin-panel h2 { margin-bottom: 6px; font-size: 1.28rem; letter-spacing: -.03em; }
.admin-panel > p { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.admin-table-wrap { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { color: var(--muted); font-size: .69rem; letter-spacing: .07em; text-transform: uppercase; }
td .button { min-height: 32px; padding: 6px 8px; font-size: .76rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.login-card { width: min(430px, calc(100% - 32px)); margin: 9vh auto 0; padding: 28px; border-radius: 20px; background: var(--paper-strong); box-shadow: var(--shadow); }
.login-card p { color: var(--muted); line-height: 1.5; }
.login-card form { display: grid; gap: 12px; }
.manage-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.manage-tab { border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; background: var(--paper-strong); font-size: .8rem; font-weight: 700; }
.manage-tab.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; padding: 12px; margin-bottom: 14px; background: #f2f6f2; border: 1px dashed var(--line); border-radius: 12px; }
.inline-form .full { grid-column: 1 / -1; }
.row-list { display: flex; flex-direction: column; gap: 8px; }
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--paper-strong); border: 1px solid var(--line); border-radius: 10px; font-size: .85rem; }

.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 8px; max-width: min(360px, calc(100% - 32px)); }
.toast { padding: 12px 14px; color: #fff; background: var(--ink); border-radius: 11px; box-shadow: var(--shadow); font-size: .87rem; line-height: 1.4; }
.toast.error { background: #8d3024; }
.loading { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid #c4d3ca; border-top-color: var(--moss-dark); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 1000px) {
  .admin-grid { grid-template-columns: .8fr 1.2fr; }
}
@media (max-width: 860px) {
  .content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-layout, .admin-grid { grid-template-columns: 1fr; }
  .hero { min-height: 410px; }
}
@media (max-width: 600px) {
  .topbar-inner, .page-width, .hero-content { width: min(100% - 24px, 1180px); }
  .topbar-inner { min-height: 64px; }
  .brand-title { font-size: .95rem; }
  .brand-subtitle { display: none; }
  .header-actions .button-quiet { display: none; }
  .hero-content { padding: 55px 0 44px; }
  .section { padding: 42px 0; }
  .section-head { display: block; }
  .type-tabs { margin-top: 16px; }
  .content-grid { grid-template-columns: 1fr; }
  .content-card { min-height: 0; }
  .search-row { grid-template-columns: 1fr; }
  .prompt-grid { grid-template-columns: 1fr; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .detail-grid { gap: 9px; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
  .admin-shell { padding-top: 24px; }
  .admin-top { align-items: flex-start; flex-direction: column; }
  .modal { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
