:root {
  color-scheme: dark;
  --rail: #1e1f22;
  --sidebar: #2b2d31;
  --surface: #313338;
  --surface-raised: #383a40;
  --surface-hover: #35373c;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --faint: #80848e;
  --line: #3f4147;
  --blurple: #5865f2;
  --light-blurple: #e0e3ff;
  --green: #23a559;
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: var(--surface); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 15%, #363b68 0, #1e1f22 48%); }
.login-card { width: min(440px, 100%); padding: 42px; border: 1px solid #42444b; border-radius: 20px; background: #2b2d31; box-shadow: 0 24px 70px #0008; text-align: center; }
.login-logo { width: 180px; margin-bottom: 20px; filter: brightness(0) invert(1); }
.login h1 { margin: 0 0 12px; font-size: 27px; }
.login p { margin: 0 auto 26px; color: var(--muted); line-height: 1.75; }
.discord-login { display: block; padding: 13px 18px; border-radius: 8px; color: #fff; background: var(--blurple); font-weight: 700; text-decoration: none; }
.discord-login:hover { background: #4752c4; }
.legal-links { display: flex; justify-content: center; gap: 18px; margin-top: 18px; font-size: 12px; }
.legal-links a { color: var(--muted); }

.app { display: grid; grid-template-columns: 72px 292px minmax(480px, 1fr) 310px; height: 100vh; overflow: hidden; }
.rail { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 8px; background: var(--rail); }
.rail-logo, .guild-button, .rail-button { display: grid; width: 48px; height: 48px; place-items: center; border: 0; border-radius: 16px; color: var(--text); background: var(--surface); transition: border-radius .18s, background .18s; }
.guild-button, .rail-button { cursor: pointer; }
.guild-button:hover, .guild-button.active { border-radius: 12px; background: var(--blurple); }
.rail-logo img { width: 31px; filter: brightness(0) invert(1); }
.guilds { display: flex; flex: 1; flex-direction: column; gap: 9px; overflow-y: auto; }
.guild-button { position: relative; font-weight: 700; }
.guild-button.active::before { position: absolute; left: -8px; width: 4px; height: 36px; border-radius: 0 4px 4px 0; background: #fff; content: ""; }
.rail-button { color: var(--muted); font-size: 22px; }
.logout-button { position: relative; }
.logout-button svg { width: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.logout-button:hover { border-radius: 12px; color: #fff; background: #da373c; }
.rail-label { position: absolute; left: 58px; z-index: 10; padding: 7px 9px; border-radius: 5px; color: #fff; background: #111214; box-shadow: 0 4px 12px #0007; font-size: 12px; font-weight: 700; opacity: 0; pointer-events: none; transform: translateX(-4px); transition: opacity .15s, transform .15s; white-space: nowrap; }
.logout-button:hover .rail-label, .logout-button:focus-visible .rail-label { opacity: 1; transform: translateX(0); }

.history { min-width: 0; background: var(--sidebar); }
.history-head { padding: 17px 14px 12px; border-bottom: 1px solid #202225; }
.history-head strong { display: block; margin: 0 4px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-list { height: calc(100vh - 104px); padding: 12px 8px 58px; overflow-y: auto; }
.load-more { position: relative; display: block; width: calc(100% - 24px); margin: -48px 12px 10px; padding: 9px; border: 0; border-radius: 6px; color: var(--text); background: var(--surface-raised); cursor: pointer; }
.mobile-back { display: none; margin-bottom: 12px; border: 0; color: var(--light-blurple); background: transparent; cursor: pointer; }
.date-label { margin: 15px 8px 7px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.conversation-item { width: 100%; margin-bottom: 3px; padding: 10px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; }
.conversation-item:hover { background: var(--surface-hover); color: var(--text); }
.conversation-item.active { color: #fff; background: var(--blurple); }
.conversation-item strong { display: block; margin-bottom: 4px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; opacity: .8; }

.main { min-width: 0; overflow-y: auto; background: var(--surface); }
.empty { display: grid; height: 100%; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty img { width: 82px; margin-bottom: 18px; opacity: .35; filter: grayscale(1) brightness(2); }
.empty h1 { margin: 0 0 7px; color: var(--text); font-size: 22px; }
.empty p { margin: 0; }
.conversation-head { padding: 28px 28px 20px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--blurple); font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.conversation-head h1 { margin: 5px 0 6px; font-size: 30px; }
.conversation-head p { margin: 0; color: var(--muted); font-size: 13px; }
.section { margin: 18px; padding: 18px; border-radius: 9px; background: #2b2d31; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-title h2, .details h2 { margin: 0; font-size: 16px; }
.section-title span { color: var(--muted); font-size: 12px; }
.participants { display: flex; flex-wrap: wrap; gap: 10px; }
.participant { display: flex; align-items: center; gap: 8px; padding: 5px 11px 5px 7px; border-radius: 999px; background: var(--surface-raised); cursor: pointer; font-size: 13px; font-weight: 600; transition: opacity .15s, filter .15s, background .15s; }
.participant:has(input:checked) { background: #454963; }
.participant:has(input:not(:checked)), .participant.unavailable { opacity: .45; filter: grayscale(1); }
.participant input { width: 15px; height: 15px; margin: 0; accent-color: var(--blurple); }
.participant.unavailable { cursor: default; }
.avatar { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--blurple); object-fit: cover; font-size: 12px; }
.audio-player { padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--rail); }
.audio-player audio { width: 100%; height: 42px; accent-color: var(--blurple); }
.processing-banner { display: flex; gap: 12px; align-items: center; margin-top: 16px; padding: 12px 14px; border: 1px solid #5865f266; border-radius: 10px; background: #5865f21f; font-size: 13px; }
.processing-banner strong { display: block; margin-bottom: 2px; font-size: 14px; }
.processing-banner span { color: var(--muted); }
.processing-banner.failed { border-color: #da373c66; background: #da373c1f; }
.processing-banner.failed .processing-spinner { display: none; }
.processing-spinner { width: 18px; height: 18px; flex: none; border: 3px solid #454963; border-top-color: var(--blurple); border-radius: 50%; animation: summary-spin .8s linear infinite; }
.processing-badge { margin-left: 8px; padding: 1px 7px; border-radius: 999px; color: var(--light-blurple); background: #454963; font-size: 10px; font-weight: 700; vertical-align: 1px; }
.conversation-item.active .processing-badge { color: #fff; background: #ffffff33; }
.audio-expired.audio-pending { border-style: solid; border-color: #5865f266; }
@media (prefers-reduced-motion: reduce) { .processing-spinner { animation: none; } }
.audio-expired { padding: 18px; border: 1px dashed #5a5d66; border-radius: 8px; color: var(--muted); text-align: center; }
.download { padding: 8px 12px; border-radius: 6px; color: #fff; background: var(--blurple); font-size: 12px; font-weight: 700; text-decoration: none; }
.content-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.content-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 8px; background: var(--rail); }
.content-tab { padding: 7px 11px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; }
.content-tab:hover { color: var(--text); }
.content-tab.active { color: #fff; background: var(--blurple); }
.transcript { max-height: 54vh; overflow-y: auto; }
.message { display: grid; grid-template-columns: 42px 1fr; gap: 10px; margin: 2px -8px; padding: 8px; border-radius: 6px; cursor: pointer; transition: background .15s, box-shadow .15s; }
.message:hover { background: #2e3035; }
.message:focus-visible { outline: 2px solid var(--blurple); outline-offset: -2px; }
.message.active { background: #3b3e55; box-shadow: inset 3px 0 var(--blurple); }
.message .avatar { width: 38px; height: 38px; }
.message-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.message-head strong { font-size: 14px; }
.message-head time { color: var(--faint); font-size: 11px; }
.message-source { padding: 2px 6px; border-radius: 4px; color: var(--light-blurple); background: #454963; font-size: 10px; font-weight: 700; }
.message p { margin: 0; color: #dbdee1; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.summary { min-height: 180px; }
.summary-state { display: flex; min-height: 180px; align-items: center; justify-content: center; gap: 13px; color: var(--muted); text-align: left; }
.summary-state strong, .summary-state span { display: block; }
.summary-state strong { margin-bottom: 5px; color: var(--text); }
.summary-state span { font-size: 12px; }
.summary-spinner { width: 22px; height: 22px; border: 3px solid #454963; border-top-color: var(--blurple); border-radius: 50%; animation: summary-spin .8s linear infinite; }
.summary-error { flex-direction: column; text-align: center; }
.summary-error button { padding: 8px 12px; border: 0; border-radius: 6px; color: #fff; background: var(--blurple); cursor: pointer; font-weight: 700; }
.summary-section { padding: 2px 0 17px; }
.summary-section + .summary-section { padding-top: 17px; border-top: 1px solid var(--line); }
.summary-section h3 { margin: 0 0 9px; color: var(--text); font-size: 14px; }
.summary-section p { margin: 0; color: #dbdee1; font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.summary-section ul { margin: 0; padding-left: 21px; color: #dbdee1; font-size: 14px; line-height: 1.7; }
.summary-section li + li { margin-top: 5px; }
.summary-section .summary-empty { color: var(--faint); }
.summary-topics { display: grid; gap: 9px; }
.summary-topics article { padding: 11px 12px; border-radius: 7px; background: var(--rail); }
.summary-topics article > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.summary-topics strong { font-size: 13px; }
.summary-topics button { padding: 3px 7px; border: 0; border-radius: 5px; color: var(--light-blurple); background: #454963; cursor: pointer; font-size: 11px; }
.summary-note { margin: 3px 0 0; color: var(--faint); font-size: 11px; line-height: 1.5; }
@keyframes summary-spin { to { transform: rotate(360deg); } }

.details { padding: 22px 18px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--rail); }
.details h2 { margin-bottom: 14px; }
.details h2:not(:first-child) { margin-top: 30px; }
.details dl { margin: 0; }
.details dl div { padding: 11px 0; border-bottom: 1px solid var(--line); }
.details dt { margin-bottom: 5px; color: var(--faint); font-size: 11px; font-weight: 700; }
.details dd { margin: 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.file-group + .file-group { margin-top: 20px; }
.file-group h3 { margin: 0 0 8px; color: var(--faint); font-size: 11px; letter-spacing: .04em; }
.file-group-list { display: grid; gap: 8px; }
.file { display: grid; gap: 10px; padding: 12px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); background: var(--sidebar); }
.file:hover:not(.unavailable) { border-color: #4b4e57; background: var(--surface); }
.file-content { min-width: 0; }
.file-heading { display: flex; align-items: center; gap: 7px; }
.file-heading strong { min-width: 0; overflow: hidden; color: var(--text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.file-format { flex: 0 0 auto; padding: 2px 5px; border-radius: 4px; color: var(--light-blurple); background: #454963; font-size: 9px; font-weight: 800; }
.file-description { display: block; margin-top: 5px; color: var(--faint); font-size: 11px; line-height: 1.45; }
.file-download { display: block; width: 100%; padding: 7px 9px; border-radius: 6px; color: var(--light-blurple); background: #3b3e55; font-size: 11px; font-weight: 700; text-align: center; text-decoration: none; }
a.file-download:hover { color: #fff; background: var(--blurple); }
.file.unavailable { opacity: .5; }
.file.unavailable .file-download { background: transparent; }
.files-empty { margin: 0; color: var(--faint); font-size: 12px; line-height: 1.6; }
.connections-button svg { width: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.connections-button { position: relative; }
.connections-button:hover { border-radius: 12px; color: #fff; background: var(--blurple); }
.connections-button:hover .rail-label, .connections-button:focus-visible .rail-label { opacity: 1; transform: translateX(0); }
.connections-dialog { width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); padding: 0; border: 1px solid #42444b; border-radius: 16px; color: var(--text); background: var(--sidebar); box-shadow: 0 24px 70px #000a; }
.connections-dialog::backdrop { background: #000a; }
.connections-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 22px 22px 14px; border-bottom: 1px solid #202225; }
.connections-head h2 { margin: 0 0 6px; font-size: 20px; outline: none; }
.connections-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.dialog-close { display: grid; width: 34px; height: 34px; flex: none; place-items: center; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.dialog-close:hover { color: var(--text); background: var(--surface-hover); }
.dialog-close svg { width: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }
.connections-list { display: grid; gap: 10px; padding: 16px 22px 22px; overflow-y: auto; }
.connection-card { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.connection-tile { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 12px; background: var(--surface-raised); font-weight: 800; }
.connection-body { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.connection-body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-host { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.connection-scopes { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.scope-chip { padding: 2px 8px; border-radius: 999px; color: var(--light-blurple); background: #454963; font-size: 11px; font-weight: 700; }
.scope-chip-warning { color: #f0b232; background: #f0b2321f; }
.connection-meta { color: var(--faint); font-size: 12px; }
.connection-revoke { padding: 8px 12px; border: 1px solid #da373c88; border-radius: 8px; color: #ff8a8d; background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; white-space: nowrap; }
.connection-revoke:hover:not(:disabled) { color: #fff; background: #da373c; }
.connection-revoke:disabled { opacity: .6; cursor: progress; }
.connections-state { display: flex; min-height: 140px; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); text-align: center; }
.connections-state strong { color: var(--text); }
.connections-state span { font-size: 13px; }
@media (max-width: 520px) {
  .connection-card { grid-template-columns: 40px 1fr; }
  .connection-revoke { grid-column: 1 / -1; }
}
.toast { position: fixed; right: 20px; bottom: 20px; padding: 12px 16px; border-radius: 8px; color: #fff; background: #111214; box-shadow: 0 8px 30px #0008; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 64px 270px minmax(420px, 1fr); }
  .details { display: none; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 58px 1fr; }
  .history { grid-column: 2; }
  .main { display: none; position: fixed; inset: 0 0 0 58px; z-index: 3; }
  .app.show-conversation .history { display: none; }
  .app.show-conversation .main { display: block; }
  .section { margin: 10px; padding: 14px; }
  .conversation-head { padding: 20px 16px; }
  .mobile-back { display: block; }
  .content-header { align-items: stretch; flex-direction: column; }
  .content-tabs { align-self: flex-start; }
  .download { align-self: flex-start; }
}
