:root {
  color-scheme: dark;
  --bg: #070b12;
  --bg-elevated: #0c121d;
  --surface: #101827;
  --surface-2: #151f31;
  --surface-soft: #ffffff08;
  --field: #0a101a;
  --text: #f7f5f2;
  --muted: #9da8b9;
  --muted-2: #738096;
  --accent: #ff6f91;
  --accent-2: #ffb45f;
  --accent-soft: #ff78901c;
  --line: #ffffff14;
  --line-strong: #ffffff22;
  --success: #69d6aa;
  --danger: #ff7f92;
  --shadow: 0 26px 80px #00000048;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% -8%, #ff54782c, transparent 28rem),
    radial-gradient(circle at 8% 96%, #ffad5d17, transparent 30rem),
    linear-gradient(145deg, #080c14 0%, #070b12 52%, #090d16 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .22;
  pointer-events: none;
  background-image: linear-gradient(#ffffff05 1px, transparent 1px), linear-gradient(90deg, #ffffff04 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, #000, transparent 75%);
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin-top: 0; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  overflow: hidden;
  border: 1px solid #ffffff1b;
  border-radius: 15px;
  background: #071026;
  box-shadow: 0 10px 28px #0007, 0 0 0 4px #ff76900a;
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.brand h1 { margin: 0 0 3px; font-size: 22px; line-height: 1.1; letter-spacing: -.02em; }
.brand-subtitle { color: var(--muted); font-size: 13px; line-height: 1.55; }

.app-shell { width: min(1540px, 100%); margin: 0 auto; padding: 22px clamp(16px, 2.2vw, 34px) 34px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  margin-bottom: 20px;
}
.top-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid #65d4a737;
  border-radius: 999px;
  background: #65d4a70d;
  color: #8ce3bf;
  font-size: 12px;
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px #69d6aa17; }

.app-layout { display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 18px; align-items: start; }
.surface {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(155deg, #131b2adf, #0d1421ed);
  box-shadow: var(--shadow);
}
.sidebar {
  position: sticky;
  top: 18px;
  grid-column: 1;
  grid-row: 1;
  min-height: calc(100vh - 118px);
  padding: 16px;
  overflow: hidden;
}
.main-surface { grid-column: 2; grid-row: 1; min-width: 0; min-height: calc(100vh - 118px); padding: clamp(18px, 2vw, 28px); }
.sidebar-head, .section-head, .workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.sidebar-head { margin-bottom: 13px; }
.sidebar h2 { margin: 0; font-size: 15px; }
.count-badge { min-width: 28px; padding: 4px 8px; border-radius: 999px; background: #ffffff0c; color: var(--muted); font-size: 12px; text-align: center; }
.sidebar-primary { width: 100%; margin-bottom: 14px; }
.people { display: grid; gap: 8px; }
.person {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text);
  background: transparent;
  text-align: right;
  cursor: pointer;
  transition: .18s ease;
}
.person:hover { border-color: var(--line); background: #ffffff08; transform: translateY(-1px); }
.person.active { border-color: #ff82964c; background: linear-gradient(135deg, #ff78901d, #ffb25d0b); }
.person-avatar, .workspace-avatar {
  display: grid;
  place-items: center;
  border: 1px solid #ffffff18;
  border-radius: 12px;
  background: linear-gradient(145deg, #ff76902b, #ffb26018);
  color: #ffd5dc;
  font-weight: 900;
}
.person-avatar { width: 40px; height: 40px; }
.person-copy { min-width: 0; }
.person strong, .person span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person strong { margin-bottom: 3px; font-size: 14px; }
.person span { color: var(--muted); font-size: 11px; }
.sidebar-tools { display: grid; gap: 7px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.sidebar-note { margin: 14px 2px 0; color: var(--muted-2); font-size: 11px; line-height: 1.7; }
.empty { padding: 28px 10px; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.8; }

.btn {
  min-height: 42px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #241018;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 26px #ff718320;
  transition: transform .16s ease, filter .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn.secondary { border: 1px solid var(--line); background: #1a2435; color: var(--text); box-shadow: none; }
.btn.ghost { border: 1px solid transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { border-color: var(--line); background: #ffffff08; color: var(--text); }
.btn.danger { border: 1px solid #ff7d9234; background: #ff657916; color: #ffb6c1; box-shadow: none; }
.btn.compact { min-height: 36px; padding: 8px 12px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

.welcome-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 18px; }
.hero-card {
  position: relative;
  min-height: 450px;
  padding: clamp(26px, 4vw, 56px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, #141e2e 0%, #101725 56%, #171624 100%);
}
.hero-card::after {
  content: "";
  position: absolute;
  width: 310px;
  height: 310px;
  inset: auto -90px -110px auto;
  border-radius: 50%;
  background: radial-gradient(circle, #ff80983a, #ffb2600b 52%, transparent 68%);
  filter: blur(3px);
}
.hero-card h2 { max-width: 680px; margin-bottom: 18px; font-size: clamp(30px, 4vw, 52px); line-height: 1.17; letter-spacing: -.045em; }
.hero-card > p { max-width: 630px; color: #c0c8d5; font-size: 16px; line-height: 1.9; }
.feature-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 40px; }
.feature-item { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #ffffff07; }
.feature-item b { display: block; margin-bottom: 6px; font-size: 13px; }
.feature-item span { color: var(--muted); font-size: 11px; line-height: 1.6; }
.form-card, .card { border: 1px solid var(--line); border-radius: 18px; background: var(--surface-soft); }
.form-card { padding: 22px; }
.form-card h3, .card h3 { margin-bottom: 7px; font-size: 16px; }
.form-card .lead, .card .lead { margin-bottom: 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }

.workspace-head { margin-bottom: 18px; padding: 2px 2px 18px; border-bottom: 1px solid var(--line); }
.workspace-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.workspace-avatar { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 16px; font-size: 19px; }
.workspace-head h2 { margin: 0 0 4px; font-size: 20px; }
.workspace-head p { margin: 0; color: var(--muted); font-size: 12px; }
.quick-stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quick-stat { min-width: 82px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 12px; background: #ffffff06; text-align: center; }
.quick-stat strong { display: block; font-size: 16px; }
.quick-stat span { color: var(--muted); font-size: 10px; }
.workspace-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -2px 18px; padding: 2px 2px 8px; scrollbar-width: none; }
.workspace-tabs::-webkit-scrollbar { display: none; }
.tab-button { min-height: 40px; padding: 9px 14px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 700; white-space: nowrap; cursor: pointer; }
.tab-button:hover { border-color: var(--line); color: var(--text); }
.tab-button.active { border-color: #ff7a9140; background: var(--accent-soft); color: #ffd5dd; }
.view-panel { display: none; }
.view-panel.active { display: block; animation: view-in .22s ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { min-width: 0; padding: 19px; }
.card.wide { grid-column: 1 / -1; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.card-header h3 { margin: 0; }
.card-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #ff7b9130; border-radius: 11px; background: var(--accent-soft); color: #ffb7c4; font-size: 16px; }
.notice { margin: 0 0 15px; padding: 12px 14px; border: 1px solid #ffb3612b; border-radius: 13px; background: #ffad5d0c; color: #decab0; font-size: 12px; line-height: 1.75; }
.memory-intro { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.memory-intro p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.memory-result h3, .analysis-result h3 { margin: 20px 0 10px; color: #dfe4ec; font-size: 13px; }
.memory-result h3:first-child { margin-top: 0; }
.memory-result ul, .analysis-result ul { margin: 8px 0; padding-right: 20px; }
.memory-result li, .analysis-result li { margin-bottom: 8px; color: #c9d0dc; font-size: 13px; line-height: 1.75; }

label { display: grid; gap: 7px; margin-bottom: 13px; color: #d8dde6; font-size: 12px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: var(--field);
  color: var(--text);
  padding: 11px 12px;
  font-weight: 400;
  transition: border-color .16s ease, box-shadow .16s ease;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: #667288; }
input:focus, select:focus, textarea:focus { border-color: #ff7c906f; box-shadow: 0 0 0 4px #ff728b0f; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 5px; }
.question { padding: 15px 0; border-bottom: 1px solid var(--line); }
.question:first-child { padding-top: 0; }
.question:last-child { border-bottom: 0; }
.question small { display: block; margin: 0 0 7px; color: var(--accent-2); font-size: 11px; font-weight: 700; }
.question strong { line-height: 1.65; }
.mini { margin: 10px 0 0 6px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: #1b2536; color: var(--text); font-size: 11px; cursor: pointer; }
.mini:hover { border-color: #ff819448; }
.analysis-result > .notice { font-size: 13px; }

.security-hero { margin-bottom: 18px; padding: 4px 2px 20px; border-bottom: 1px solid var(--line); }
.security-hero h2 { margin-bottom: 8px; font-size: 25px; }
.security-hero p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.8; }
.event-list .question:last-child { border-bottom: 0; }

#toast {
  position: fixed;
  inset: auto 24px 24px auto;
  z-index: 30;
  max-width: min(390px, calc(100vw - 48px));
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #182234;
  box-shadow: 0 18px 60px #0009;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}
#toast.show { opacity: 1; transform: none; }
#toast.error { border-color: #ff718b52; color: #ffc0ca; }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: clamp(16px, 3vw, 40px); }
.login-shell {
  width: min(1120px, 100%);
  min-height: min(680px, calc(100vh - 64px));
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: #0e1522e8;
  box-shadow: 0 36px 120px #0009;
}
.login-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 5vw, 66px);
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 20%, #ff6f9145, transparent 20rem),
    radial-gradient(circle at 10% 90%, #ffb45f24, transparent 24rem),
    linear-gradient(145deg, #151d2d, #0b111c 70%);
}
.login-visual::after { content: ""; position: absolute; width: 420px; height: 420px; inset: auto -170px -180px auto; border: 1px solid #ffffff12; border-radius: 50%; box-shadow: 0 0 0 70px #ffffff05, 0 0 0 140px #ffffff03; }
.login-visual .brand { position: relative; z-index: 1; }
.login-copy { position: relative; z-index: 1; max-width: 570px; }
.login-copy h2 { margin: 0 0 18px; font-size: clamp(34px, 4vw, 55px); line-height: 1.2; letter-spacing: -.045em; }
.login-copy p { margin: 0; color: #c4cbd6; font-size: 15px; line-height: 1.9; }
.login-points { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.login-point { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: #ffffff08; color: #d9dee7; font-size: 11px; }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(30px, 5vw, 58px); background: #0d1420; }
.login-panel h2 { margin-bottom: 9px; font-size: 24px; }
.login-panel > p { margin-bottom: 24px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.login-notice { margin-bottom: 20px; padding: 13px 14px; border: 1px solid #ffb45f2c; border-radius: 13px; background: #ffb45f0b; color: #dfccb4; font-size: 12px; line-height: 1.8; }
.login-panel .btn { width: 100%; }
.login-error { min-height: 22px; margin-top: 12px; color: #ffafbd; font-size: 12px; }
.login-private { display: flex; gap: 9px; align-items: flex-start; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted-2); font-size: 11px; line-height: 1.7; }
.login-private::before { content: "✓"; display: grid; place-items: center; width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; background: #69d6aa13; color: var(--success); }

@media (max-width: 980px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-column: 1; grid-row: auto; min-height: auto; }
  .main-surface { grid-column: 1; grid-row: auto; min-height: 620px; }
  .people { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .person { min-width: 220px; }
  .sidebar-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-note { display: none; }
  .welcome-grid { grid-template-columns: 1fr; }
  .hero-card { min-height: auto; }
  .login-shell { min-height: auto; grid-template-columns: 1fr; }
  .login-visual { min-height: 390px; }
}

@media (max-width: 680px) {
  .app-shell { padding: 14px 12px 24px; }
  .topbar { align-items: flex-start; margin-bottom: 14px; }
  .brand-mark { width: 43px; height: 43px; flex-basis: 43px; border-radius: 13px; }
  .brand h1 { font-size: 19px; }
  .brand-subtitle, .status-pill { display: none; }
  .top-actions .btn { min-height: 38px; padding: 8px 11px; font-size: 11px; }
  .surface { border-radius: 19px; }
  .main-surface { padding: 15px; }
  .content-grid, .feature-strip { grid-template-columns: 1fr; }
  .hero-card { padding: 25px 20px; }
  .hero-card h2 { font-size: 31px; }
  .feature-strip { margin-top: 26px; }
  .workspace-head { align-items: flex-start; }
  .quick-stats { display: none; }
  .card.wide { grid-column: auto; }
  .memory-intro { align-items: flex-start; flex-direction: column; }
  .login-body { padding: 0; }
  .login-shell { min-height: 100vh; border: 0; border-radius: 0; }
  .login-visual { min-height: 350px; padding: 28px 22px; }
  .login-copy h2 { font-size: 35px; }
  .login-panel { padding: 30px 22px 36px; }
  #toast { inset: auto 12px 12px 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
