: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; }

.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; }
.search { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 6px; color: var(--faint); background: var(--rail); }
.search input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.conversation-list { height: calc(100vh - 104px); padding: 12px 8px 24px; overflow-y: auto; }
.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); }
.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; }
.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 p { margin: 0; color: #dbdee1; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }

.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 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; padding: 11px; border-radius: 7px; color: var(--muted); background: var(--sidebar); font-size: 12px; }
.file a { color: var(--light-blurple); text-decoration: none; }
.file.unavailable { opacity: .5; }
.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; }
}
