:root {
  --red: #e60000;
  --yellow: #ffd700;
  --ink: #0a0a0b;
  --panel: #111114;
  --panel-2: #19191e;
  --line: rgba(255,255,255,.12);
  --muted: rgba(255,255,255,.58);
  --font-jp: "Noto Sans JP", sans-serif;
  --font-en: "Oswald", sans-serif;
  --font-display: "Bebas Neue", sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--ink); }
body { margin: 0; color: #fff; background: var(--ink); font-family: var(--font-jp); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
[hidden] { display: none !important; }
.eyebrow { margin: 0; color: var(--yellow); font-family: var(--font-en); font-size: 11px; font-weight: 700; letter-spacing: .19em; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand b { font-size: 18px; letter-spacing: .03em; }
.brand b span { color: var(--red); }
.brand-mark { display: flex; width: 34px; height: 34px; align-items: end; justify-content: center; gap: 3px; padding: 7px; background: var(--red); clip-path: polygon(15% 0,85% 0,100% 15%,100% 85%,85% 100%,15% 100%,0 85%,0 15%); }
.brand-mark i { display: block; width: 4px; background: #fff; }
.brand-mark i:nth-child(1) { height: 10px; transform: rotate(-13deg); }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-mark i:nth-child(3) { height: 10px; transform: rotate(13deg); }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(380px, .8fr) minmax(500px, 1.2fr); }
.login-card { display: flex; min-height: 100vh; flex-direction: column; justify-content: center; padding: clamp(34px, 7vw, 96px); background: #0c0c0e; }
.login-card .brand { position: absolute; top: 34px; left: clamp(34px, 7vw, 96px); }
.login-card h1 { margin: 22px 0 18px; font-size: clamp(52px, 7vw, 92px); line-height: .94; letter-spacing: -.055em; }
.login-card h1 em { color: var(--red); font-style: normal; }
.login-copy { max-width: 500px; margin: 0 0 34px; color: var(--muted); font-size: 14px; line-height: 1.9; }
#login-form { display: grid; gap: 18px; max-width: 460px; }
#login-form label { color: var(--yellow); font-family: var(--font-en); font-size: 10px; letter-spacing: .16em; }
#login-form input { width: 100%; margin-top: 8px; padding: 15px 16px; color: #fff; background: #17171a; border: 1px solid var(--line); border-radius: 0; }
#login-form button, .user-form button { display: flex; justify-content: space-between; padding: 15px 18px; color: #fff; background: var(--red); border: 0; font-family: var(--font-en); font-weight: 700; letter-spacing: .16em; }
.discord-login { display: flex; max-width: 460px; align-items: center; gap: 12px; padding: 17px 18px; color: #fff; background: #5865f2; font-family: var(--font-en); font-weight: 700; letter-spacing: .12em; text-decoration: none; }
.discord-login > span:last-child { margin-left: auto; }
.discord-mark { display: grid; width: 26px; height: 26px; place-items: center; background: #fff; color: #5865f2; border-radius: 50%; font-size: 14px; line-height: 1; }
.emergency-login { max-width: 460px; margin-top: 20px; color: var(--muted); font-size: 11px; }
.emergency-login summary { cursor: pointer; }
.emergency-login #login-form { margin-top: 16px; }
.form-error { margin: 0; color: #ff7777; font-size: 12px; }
.back-link { margin-top: 28px; color: var(--muted); font-family: var(--font-en); font-size: 10px; letter-spacing: .13em; text-decoration: none; }
.login-art { position: relative; display: grid; overflow: hidden; place-items: center; background: linear-gradient(135deg, rgba(230,0,0,.88), rgba(92,0,0,.92)); }
.login-art::before { content: ""; position: absolute; inset: -15%; background: repeating-linear-gradient(118deg, transparent 0 56px, rgba(0,0,0,.12) 57px 59px); transform: rotate(-7deg); }
.login-art span { position: absolute; top: 8%; right: -2%; color: rgba(255,255,255,.1); font-family: var(--font-display); font-size: 13vw; letter-spacing: .02em; writing-mode: vertical-rl; }
.login-art strong { position: relative; color: #fff; font-family: var(--font-display); font-size: 30vw; font-weight: 400; line-height: 1; text-shadow: 24px 24px 0 rgba(0,0,0,.16); }
.login-art small { position: absolute; right: 34px; bottom: 34px; font-family: var(--font-en); letter-spacing: .18em; }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; display: grid; height: 72px; grid-template-columns: 230px 1fr auto; align-items: center; gap: 24px; padding: 0 26px; background: rgba(8,8,9,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.topbar-title { display: flex; align-items: baseline; gap: 12px; }
.topbar-title span { color: var(--yellow); font-family: var(--font-en); font-size: 10px; letter-spacing: .15em; }
.topbar-title strong { font-size: 13px; }
.user-menu { display: flex; align-items: center; gap: 14px; font-size: 12px; }
.icon-button, .detail-toolbar button, .pagination button, .admin-card button { padding: 9px 12px; color: #fff; background: transparent; border: 1px solid var(--line); font-family: var(--font-en); font-size: 10px; font-weight: 700; letter-spacing: .1em; }
main { display: grid; min-height: calc(100vh - 72px); grid-template-columns: 82px 1fr; }
.rail { position: sticky; top: 72px; display: flex; height: calc(100vh - 72px); flex-direction: column; align-items: stretch; background: #0d0d0f; border-right: 1px solid var(--line); }
.rail-button { display: grid; gap: 6px; place-items: center; min-height: 82px; padding: 10px 4px; color: var(--muted); background: transparent; border: 0; border-bottom: 1px solid var(--line); font-size: 10px; }
.rail-button span { color: var(--yellow); font-size: 19px; }
.rail-button.active { color: #fff; background: rgba(230,0,0,.16); box-shadow: inset 4px 0 var(--red); }
.rail-status { display: flex; gap: 8px; align-items: center; margin-top: auto; padding: 18px 10px; color: var(--muted); font-family: var(--font-en); font-size: 8px; line-height: 1.6; letter-spacing: .08em; }
.rail-status i { width: 7px; height: 7px; flex: 0 0 auto; background: #4ed58a; border-radius: 50%; box-shadow: 0 0 10px #4ed58a; }
.workspace { display: grid; min-width: 0; grid-template-columns: minmax(360px, 42%) minmax(0, 58%); }
.list-panel { min-width: 0; padding: 30px; background: #101012; border-right: 1px solid var(--line); }
.panel-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 22px; }
.panel-heading > div { order: 1; margin-right: auto; }
.panel-heading .compose-button { order: 2; }
.panel-heading #refresh-button { order: 3; }
.compose-button, .reply-button { padding: 10px 13px; color: #fff; background: var(--red); border: 0; font-family: var(--font-en); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.panel-heading .compose-button { margin-right: 8px; }
.panel-heading h1, .admin-heading h1 { margin: 5px 0 0; font-size: 29px; }
.filters { display: grid; gap: 9px; }
.filters input, .filters select, .assignment-bar select, .user-form input, .user-form select { width: 100%; padding: 12px 13px; color: #fff; background: #1b1b1f; border: 1px solid var(--line); border-radius: 0; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.list-summary { min-height: 38px; padding: 13px 2px 8px; color: var(--muted); font-size: 11px; }
.email-list { display: grid; border-top: 1px solid var(--line); }
.email-card { position: relative; display: grid; gap: 7px; width: 100%; padding: 18px 14px 18px 20px; color: #fff; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.email-card:hover, .email-card.active { background: rgba(255,255,255,.045); }
.email-card.active { box-shadow: inset 4px 0 var(--red); }
.email-card.unread::before { content: ""; position: absolute; top: 24px; left: 4px; width: 7px; height: 7px; background: var(--yellow); border-radius: 50%; }
.email-card-head, .email-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.email-card-from { overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.email-card-time { flex: 0 0 auto; color: var(--muted); font-family: var(--font-en); font-size: 10px; }
.email-card-subject { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.email-card-meta { justify-content: start; color: var(--muted); font-size: 10px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; }
.status-unhandled { background: #ff4d4d; }
.status-in_progress { background: var(--yellow); }
.status-replied { background: #4aa8ff; }
.status-completed { background: #55d98b; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 18px; }
.pagination button:disabled { opacity: .3; cursor: default; }
.pagination span { color: var(--muted); font-family: var(--font-en); font-size: 10px; letter-spacing: .1em; }
.detail-panel { min-width: 0; background: #151519; }
.empty-detail { display: grid; min-height: calc(100vh - 72px); place-content: center; padding: 40px; color: var(--muted); text-align: center; }
.empty-detail span { color: rgba(255,215,0,.28); font-size: 70px; }
.empty-detail h2 { margin: 12px 0 7px; color: #fff; }
.empty-detail p { max-width: 380px; line-height: 1.8; }
.detail-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 30px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; }
.detail-toolbar button { display: none; }
.detail-reply-bar { display: flex; justify-content: flex-end; padding: 14px 38px 0; }
.detail-header { padding: 34px 38px 28px; border-bottom: 1px solid var(--line); }
.status-pill { display: inline-block; margin-bottom: 15px; padding: 5px 8px; color: #0b0b0b; font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.detail-header h2 { margin: 0 0 26px; font-size: clamp(24px, 3vw, 38px); line-height: 1.35; }
.detail-header dl { display: grid; gap: 8px; margin: 0; }
.detail-header dl div { display: grid; grid-template-columns: 56px 1fr; gap: 12px; }
.detail-header dt { color: var(--yellow); font-family: var(--font-en); font-size: 9px; letter-spacing: .14em; }
.detail-header dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.assignment-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px 38px; background: rgba(0,0,0,.25); border-bottom: 1px solid var(--line); }
.assignment-bar label { color: var(--yellow); font-family: var(--font-en); font-size: 9px; letter-spacing: .14em; }
.assignment-bar select { margin-top: 7px; }
.message-section, .attachments-section, .history-section { padding: 30px 38px; border-bottom: 1px solid var(--line); }
.section-label { margin: 0 0 18px; color: var(--yellow); font-family: var(--font-en); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
.message-body { overflow-wrap: anywhere; color: rgba(255,255,255,.86); font-size: 14px; line-height: 1.9; white-space: pre-wrap; }
.message-body a { color: #75baff; word-break: break-all; }
.attachment-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.attachment-item + .attachment-item { margin-top: 8px; }
.attachment-item strong { display: block; overflow-wrap: anywhere; font-size: 12px; }
.attachment-item small { color: var(--muted); }
.attachment-item a { flex: 0 0 auto; padding: 8px 11px; color: var(--yellow); border: 1px solid rgba(255,215,0,.4); font-size: 10px; text-decoration: none; }
.history-section ol { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }
.history-item { display: grid; grid-template-columns: 8px 1fr auto; gap: 11px; align-items: center; color: var(--muted); font-size: 11px; }
.history-item i { width: 8px; height: 8px; background: var(--red); border-radius: 50%; }
.history-item time { font-family: var(--font-en); font-size: 9px; }
.admin-view { min-width: 0; padding: clamp(30px, 5vw, 70px); }
.admin-heading { margin-bottom: 36px; }
.admin-heading > p:last-child { color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(440px, 1.2fr); gap: 22px; }
.admin-card { padding: 28px; background: var(--panel); border: 1px solid var(--line); }
.admin-card-title { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.admin-card-title > div { display: flex; align-items: center; gap: 12px; }
.admin-card-title span { color: var(--red); font-family: var(--font-display); font-size: 34px; }
.admin-card-title h2 { margin: 0; font-size: 21px; }
.admin-card-title button { color: var(--yellow); border-color: rgba(255,215,0,.4); }
.status-grid { display: grid; gap: 0; margin: 0; }
.status-grid div { display: grid; grid-template-columns: 130px 1fr; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.status-grid dt { color: var(--muted); font-size: 11px; }
.status-grid dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; }
.user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 22px; padding: 18px; background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.user-form button, .user-form .form-error { grid-column: 1 / -1; }
.user-list { display: grid; }
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 15px 0; border-top: 1px solid var(--line); }
.user-row strong { display: block; font-size: 13px; }
.user-row small { color: var(--muted); }
.user-row button { padding: 6px 8px; }
.user-row.inactive { opacity: .45; }
.toast { position: fixed; z-index: 99; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); padding: 14px 18px; color: #111; background: var(--yellow); box-shadow: 0 14px 50px rgba(0,0,0,.5); font-size: 12px; font-weight: 700; }
.modal-open { overflow: hidden; }
.compose-overlay { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.78); backdrop-filter: blur(8px); }
.compose-panel { display: grid; gap: 16px; width: min(720px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; padding: 28px; background: #141418; border: 1px solid var(--line); box-shadow: 0 28px 90px rgba(0,0,0,.7); }
.compose-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.compose-header h2 { margin: 5px 0 0; font-size: 28px; }
.compose-header button { width: 38px; height: 38px; color: #fff; background: transparent; border: 1px solid var(--line); font-size: 22px; }
.compose-panel > label { display: grid; gap: 7px; color: var(--yellow); font-family: var(--font-en); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.compose-panel label small { color: var(--muted); font-family: var(--font-jp); font-weight: 400; letter-spacing: 0; }
.compose-panel input, .compose-panel textarea { width: 100%; padding: 13px 14px; color: #fff; background: #1c1c21; border: 1px solid var(--line); border-radius: 0; }
.compose-panel textarea { min-height: 220px; resize: vertical; line-height: 1.7; }
.compose-panel input[type="file"] { color: var(--muted); }
.compose-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.compose-actions button { padding: 12px 20px; color: #fff; background: transparent; border: 1px solid var(--line); font-weight: 700; }
.compose-actions #compose-submit { background: var(--red); border-color: var(--red); }
.compose-actions button:disabled { opacity: .45; cursor: wait; }
.loading { opacity: .55; pointer-events: none; }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .detail-panel { position: fixed; z-index: 30; inset: 72px 0 0 82px; overflow-y: auto; transform: translateX(110%); transition: transform .2s ease; }
  .detail-panel.open { transform: translateX(0); }
  .detail-toolbar button { display: block; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .topbar { height: 66px; grid-template-columns: 1fr auto; padding: 0 15px; }
  .topbar-title { display: none; }
  .user-menu #current-user { display: none; }
  main { min-height: calc(100vh - 66px); grid-template-columns: 1fr; padding-bottom: 61px; }
  .rail { position: fixed; z-index: 25; top: auto; right: 0; bottom: 0; left: 0; height: 62px; flex-direction: row; background: rgba(10,10,11,.98); border-top: 1px solid var(--line); border-right: 0; }
  .rail-button { width: 50%; min-height: 0; border-right: 1px solid var(--line); border-bottom: 0; }
  .rail-button.active { box-shadow: inset 0 4px var(--red); }
  .rail-status { display: none; }
  .list-panel { padding: 22px 14px; }
  .detail-panel { inset: 66px 0 62px; }
  .detail-header, .message-section, .attachments-section, .history-section { padding-inline: 20px; }
  .detail-reply-bar { padding-inline: 20px; }
  .assignment-bar { grid-template-columns: 1fr; padding-inline: 20px; }
  .admin-view { padding: 26px 15px; }
  .admin-card { padding: 20px 16px; }
  .user-form { grid-template-columns: 1fr; }
  .user-form button, .user-form .form-error { grid-column: auto; }
  .panel-heading { flex-wrap: wrap; }
  .panel-heading > div { width: 100%; margin-bottom: 12px; }
  .panel-heading .compose-button { margin-left: 0; margin-right: auto; }
  .compose-overlay { padding: 0; place-items: stretch; }
  .compose-panel { width: 100%; max-height: 100vh; min-height: 100vh; padding: 22px 16px; }
}
