:root {
  --bg: #070d1c;
  --bg2: #0c1630;
  --panel: #101d3b;
  --line: #22365f;
  --text: #dbe7ff;
  --muted: #8ea3c8;
  --sky: #6cc6ff;
  --sky-dim: #2b6fa3;
  --blush: #ff8fb7;
  --ok: #58e0a6;
  --warn: #ffcc66;
  --mono: "M PLUS 1 Code", ui-monospace, monospace;
  --sans: "Zen Kaku Gothic New", system-ui, sans-serif;
  --r: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); line-height: 1.8; font-size: 16px;
  background-image:
    radial-gradient(900px 500px at 85% -10%, rgba(108,198,255,.14), transparent 60%),
    linear-gradient(rgba(108,198,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108,198,255,.035) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
  overflow-x: hidden;
}
.scan { position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.08) 0 1px, transparent 1px 3px); opacity: .35; }
a { color: var(--sky); }
.mono { font-family: var(--mono); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 48px); background: rgba(7,13,28,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.brand { font-family: var(--mono); font-weight: 600; letter-spacing: .12em; color: var(--text); text-decoration: none; }
.brand-mark { color: var(--sky); }
.brand-ver { margin-left: 8px; font-size: 11px; padding: 1px 6px; border: 1px solid var(--sky-dim); border-radius: 4px; color: var(--sky); }
.topbar nav { display: flex; gap: clamp(10px, 3vw, 28px); }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--sky); }

main { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* hero */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(20px, 5vw, 64px); align-items: center;
  min-height: min(86vh, 760px); padding: 40px 0; }
.sys { font-family: var(--mono); color: var(--sky); font-size: 13px; margin: 0 0 8px; }
.caret { display: inline-block; width: 8px; height: 14px; background: var(--sky); margin-left: 4px; vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
h1 { font-size: clamp(64px, 12vw, 128px); line-height: 1; margin: 0; letter-spacing: .04em; font-weight: 700;
  text-shadow: 0 0 32px rgba(108,198,255,.35); }
.catch { font-family: var(--mono); color: var(--sky); margin: 14px 0 6px; font-size: clamp(15px, 2vw, 18px); }
.intro { color: var(--muted); max-width: 34em; margin: 0 0 24px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.status { list-style: none; padding: 0; margin: 28px 0 0; display: flex; gap: 22px; font-family: var(--mono); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.status b { color: var(--text); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 8px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.warn { background: var(--warn); }

.frame { position: relative; aspect-ratio: 3/4; border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(160deg, var(--bg2), var(--panel)); overflow: hidden; }
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; z-index: 1; }
.avatar-fallback { position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  font-size: 120px; color: var(--sky-dim); font-family: var(--mono); }
.avatar-fallback small { font-size: 12px; letter-spacing: .3em; color: var(--muted); }
.corner { position: absolute; width: 18px; height: 18px; border: 2px solid var(--sky); z-index: 2; }
.tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--sky-dim); color: var(--text); background: transparent; text-decoration: none;
  font: 500 15px var(--sans); cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--sky); color: var(--sky); }
.btn.primary { background: var(--sky); color: #04111f; border-color: var(--sky); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); color: #04111f; }
.btn.ghost { margin: 18px auto 0; display: flex; }
.btn:disabled { opacity: .5; cursor: wait; }

/* sections */
.block { padding: 72px 0 24px; }
h2 { font-family: var(--mono); font-size: clamp(24px, 4vw, 34px); letter-spacing: .08em; margin: 0 0 22px;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
h2 .idx { color: var(--sky); font-size: .55em; }
h2 small { font-family: var(--sans); font-size: 14px; color: var(--muted); letter-spacing: 0; }
.note { color: var(--muted); margin: -8px 0 20px; }
.note.small { font-size: 12.5px; margin-top: 14px; }

/* profile */
.spec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(16px, 3vw, 28px); }
.spec dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 32px; margin: 0; }
.spec dl > div { display: grid; grid-template-columns: 7em 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.spec dt { font-family: var(--mono); color: var(--sky); font-size: 13px; padding-top: 2px; }
.spec dd { margin: 0; }
.links { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.links:empty { display: none; }

/* diary */
.diary-list { display: grid; gap: 14px; }
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px clamp(16px, 3vw, 26px); }
.entry-head { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; cursor: pointer; }
.entry-date { font-family: var(--mono); color: var(--sky); font-size: 13px; }
.entry-title { font-size: 18px; font-weight: 700; margin: 0; }
.entry-body { white-space: pre-wrap; color: #c9d7f2; margin: 12px 0 0; }
.entry.collapsed .entry-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry .more { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 8px; background: none; border: 0; padding: 0; cursor: pointer; }
.empty { color: var(--muted); font-family: var(--mono); font-size: 14px; }

/* talk */
.console { background: #050a16; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.console-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.console-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.console-bar em { margin-left: 8px; font: 12px var(--mono); color: var(--muted); font-style: normal; }
.log { height: min(56vh, 460px); overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: #17305c; border-bottom-right-radius: 4px; }
.msg.null { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.null::before { content: "NULL>"; display: block; font: 600 11px var(--mono); color: var(--sky); margin-bottom: 2px; }
.msg.sys { align-self: center; font: 12px var(--mono); color: var(--muted); background: none; padding: 2px; }
.msg.crisis { border-color: var(--blush); }
.typing::after { content: "処理中"; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: "処理中"; } 25% { content: "処理中."; } 50% { content: "処理中.."; } 75% { content: "処理中..."; } }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: var(--bg2); }
.chat-form input { flex: 1; min-width: 0; background: #050a16; border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); padding: 10px 16px; font: 15px var(--sans); }
.chat-form input:focus { outline: none; border-color: var(--sky); }

.consent { display: flex; align-items: center; gap: 8px; padding: 0 16px 12px; background: var(--bg2);
  font-size: 13px; color: var(--muted); cursor: pointer; }
.consent input { accent-color: var(--sky); width: 16px; height: 16px; }

/* talk log */
.log-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.logcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; }
.logcard-head { display: flex; justify-content: space-between; gap: 8px; font: 12px var(--mono); color: var(--muted); }
.logcard-head b { color: var(--sky); font-weight: 600; }
.logcard .q, .logcard .a { margin: 0; padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.logcard .q { background: #17305c; align-self: flex-end; max-width: 92%; }
.logcard .a { background: #050a16; border: 1px solid var(--line); align-self: flex-start; max-width: 92%; }
.logcard .a::before { content: "NULL>"; display: block; font: 600 11px var(--mono); color: var(--sky); }
.logcard .memo { margin: 0; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.logcard .memo::before { content: "// "; font-family: var(--mono); color: var(--sky-dim); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 48px 16px; border-top: 1px solid var(--line); margin-top: 64px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 28px; }
  .hero-visual { order: -1; max-width: 300px; width: 70%; margin: 0 auto; }
  .spec dl { grid-template-columns: 1fr; }
  .topbar nav a { font-size: 13px; }
  .msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) { .caret, .typing::after { animation: none; } html { scroll-behavior: auto; } }
