@font-face {
  font-family: "DM Sans";
  src: url("/assets/fonts/dm-sans-400.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope-700.ttf") format("truetype");
  font-weight: 700 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --blue: #0874ef;
  --blue-bright: #0875f5;
  --cyan: #00d9bd;
  --deep: #071a3d;
  --green: #00c991;
  --ink: #111827;
  --navy: #0c2148;
  --muted: #61708a;
  --soft: #f4f8fd;
  --soft-blue: #e8f3ff;
  --line: #dce5ef;
  --white: #ffffff;
  --danger: #e5484d;
  --danger-dark: #c9343a;
  --danger-soft: #fff0f1;
  --warning: #d99100;
  --success: #08753d;
  --shadow: 0 28px 70px rgba(20, 56, 101, .14);
  --body: "DM Sans", sans-serif;
  --display: "Manrope", sans-serif;
  --mono: "DM Sans", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--soft); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(8, 116, 239, .10), transparent 33rem),
    radial-gradient(circle at 100% 100%, rgba(0, 217, 189, .10), transparent 32rem),
    var(--soft);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
svg { display: block; }

.ambient {
  position: fixed;
  z-index: 0;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(3px);
}

.ambient-one {
  top: -280px;
  right: -140px;
  background: rgba(8, 116, 239, .08);
}

.ambient-two {
  bottom: -310px;
  left: -180px;
  background: rgba(0, 217, 189, .08);
}

.underchat-logo {
  display: inline-flex;
  align-items: center;
  font: 800 30px/1 var(--display);
  letter-spacing: -.06em;
}

.underchat-logo > span { color: var(--blue); }
.underchat-logo > strong { color: var(--cyan); font-weight: 800; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  color: var(--blue);
  font: 800 11px/1 var(--display);
  letter-spacing: .13em;
  text-transform: uppercase;
}

.eyebrow > span {
  width: 26px;
  height: 2px;
  background: var(--cyan);
}

.login-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr);
  width: min(1140px, calc(100% - 48px));
  min-height: min(680px, calc(100vh - 64px));
  margin: 32px auto;
  overflow: hidden;
  border: 1px solid rgba(220, 229, 239, .85);
  border-radius: 28px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
  animation: shell-in .65s cubic-bezier(.2, .8, .2, 1) both;
}

.login-story {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 650px;
  padding: 58px;
  overflow: hidden;
  color: var(--white);
  background:
    radial-gradient(circle at 90% 15%, rgba(0, 217, 189, .42), transparent 18rem),
    linear-gradient(145deg, #0875f5 0%, #075fd2 50%, #071a3d 120%);
}

.login-story::before,
.login-story::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 50%;
  pointer-events: none;
}

.login-story::before {
  right: -170px;
  bottom: -210px;
  width: 520px;
  height: 520px;
  box-shadow: inset 0 0 0 70px rgba(255, 255, 255, .018), inset 0 0 0 140px rgba(255, 255, 255, .018);
}

.login-story::after {
  right: 80px;
  bottom: 80px;
  width: 84px;
  height: 84px;
  background: rgba(0, 217, 189, .22);
  border-color: rgba(0, 217, 189, .5);
}

.login-story .underchat-logo {
  position: relative;
  z-index: 1;
  width: fit-content;
  padding: 14px 17px;
  border-radius: 15px;
  background: var(--white);
  box-shadow: 0 16px 34px rgba(7, 26, 61, .16);
}

.login-story-copy {
  position: relative;
  z-index: 1;
  margin: auto 0;
  max-width: 470px;
}

.login-story h1 {
  margin: 0;
  color: var(--white);
  font: 700 clamp(40px, 4vw, 56px)/1.08 var(--display);
  letter-spacing: -.04em;
}

.login-story-copy p {
  max-width: 390px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, .82);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.45;
}

.login-story-copy strong {
  color: #a8fff2;
  font-family: var(--display);
  font-weight: 700;
}

.login-panel {
  position: relative;
  display: flex;
  align-items: center;
  padding: 70px 64px;
  background: rgba(255, 255, 255, .94);
}

.login-form-wrap { width: 100%; max-width: 410px; margin: auto; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px 15px;
  margin: 0 0 24px;
  border: 1px solid #f4c5c7;
  border-radius: 12px;
  background: var(--danger-soft);
  color: #9f242a;
  font-size: 13px;
  line-height: 1.45;
}

.alert-icon {
  display: grid;
  flex: 0 0 20px;
  height: 20px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: 800 11px/1 var(--display);
}

.login-form { display: grid; gap: 22px; }
.field { display: grid; gap: 9px; }

.field > span:first-child,
.channel-field > span:first-child {
  color: var(--navy);
  font: 800 11px/1 var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.input-shell,
.channel-input-shell {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--white);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}

.input-shell:focus-within,
.channel-input-shell:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(8, 116, 239, .10);
}

.input-shell > svg {
  width: 19px;
  margin-left: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
}

.input-shell input {
  width: 100%;
  min-width: 0;
  height: 56px;
  padding: 0 48px 0 13px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 15px;
}

input::placeholder { color: #9ba8ba; }

.password-toggle {
  position: absolute;
  right: 10px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.password-toggle svg {
  width: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
}

.password-toggle:hover,
.password-toggle.is-active { background: var(--soft-blue); }
.password-toggle:hover svg,
.password-toggle.is-active svg { stroke: var(--blue); }

.primary-button,
.danger-button,
.secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 54px;
  border: 0;
  border-radius: 13px;
  font: 800 13px/1 var(--display);
  cursor: pointer;
  transition: transform .18s, background .18s, box-shadow .18s, opacity .18s;
}

.primary-button {
  margin-top: 6px;
  color: var(--white);
  background: var(--blue);
  box-shadow: 0 14px 28px rgba(8, 116, 239, .22);
}

.primary-button:hover {
  transform: translateY(-2px);
  background: var(--blue-bright);
  box-shadow: 0 18px 34px rgba(8, 116, 239, .28);
}

.primary-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 78px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(220, 229, 239, .9);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
}

.brand-lockup { font-size: 26px; }
.brand > small {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font: 700 11px/1 var(--display);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.topbar-actions { display: flex; align-items: center; gap: 16px; }

.environment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--success);
  background: #f0fbf5;
  font: 700 11px/1 var(--display);
}

.environment-chip span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.user-chip > span:last-child { display: grid; gap: 3px; }
.user-chip strong { color: var(--navy); font: 700 13px/1 var(--display); }
.user-chip small { color: var(--muted); font-size: 11px; }

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: var(--blue);
  background: var(--soft-blue);
  font: 800 13px/1 var(--display);
}

.logout-button {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--white);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}

.logout-button:hover { border-color: #f0afb2; color: var(--danger); background: var(--danger-soft); }
.logout-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.dashboard-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
  padding: 68px 0 100px;
}

.hero-section {
  display: grid;
  grid-template-columns: 1fr 340px;
  align-items: end;
  gap: 80px;
  padding: 0 0 48px;
  animation: rise-in .6s ease both;
}

.hero-section h1 {
  margin: 0;
  color: var(--deep);
  font: 700 clamp(48px, 6vw, 76px)/1.02 var(--display);
  letter-spacing: -.055em;
}

.hero-section h1 em { color: var(--blue); font-style: normal; }

.hero-aside {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: start;
  padding-bottom: 5px;
}

.hero-index {
  display: grid;
  min-width: 48px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  color: var(--blue);
  background: var(--soft-blue);
  font: 800 12px/1 var(--display);
}

.hero-aside p { margin: -3px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(520px, 1.12fr);
  gap: 22px;
}

.control-card,
.topics-card,
.result-panel {
  border: 1px solid rgba(220, 229, 239, .9);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 16px 46px rgba(20, 56, 101, .08);
}

.control-card { padding: 38px; animation: rise-in .6s .08s ease both; }
.topics-card { padding: 38px 0 0; overflow: hidden; animation: rise-in .6s .14s ease both; }

.section-heading { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 34px; }
.section-heading.compact { padding: 0 38px; margin-bottom: 26px; }

.step-number {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 11px;
  color: var(--blue);
  background: var(--soft-blue);
  font: 800 11px/1 var(--display);
}

.section-heading p {
  margin: 0 0 5px;
  color: var(--muted);
  font: 700 10px/1 var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.section-heading h2 { margin: 0; color: var(--deep); font: 700 22px/1.25 var(--display); letter-spacing: -.025em; }
.channel-field { display: grid; gap: 10px; }
.channel-input-shell { height: 60px; }
.input-prompt { padding-left: 18px; color: var(--blue); font: 800 22px/1 var(--display); }

.channel-input-shell input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 44px 0 10px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
}

.validation-mark {
  position: absolute;
  right: 16px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: transparent;
  font: 800 11px/1 var(--display);
  transition: .2s;
}

.channel-input-shell.is-valid { border-color: rgba(0, 201, 145, .65); }
.channel-input-shell.is-valid .validation-mark { border-color: var(--green); color: var(--green); background: #f0fbf5; }

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.field-error { color: var(--danger); text-align: right; }

.danger-note {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px;
  margin: 30px 0 20px;
  border: 1px solid #f5d0d2;
  border-radius: 13px;
  background: var(--danger-soft);
}

.danger-note svg { width: 20px; flex: 0 0 20px; fill: none; stroke: var(--danger); stroke-width: 1.6; }
.danger-note div { display: grid; gap: 4px; }
.danger-note strong { color: #9f242a; font: 700 13px/1.2 var(--display); }
.danger-note span { color: #7e4b4e; font-size: 12px; line-height: 1.5; }

.danger-button {
  width: 100%;
  justify-content: space-between;
  padding: 0 20px;
  color: var(--white);
  background: var(--danger);
  box-shadow: 0 12px 24px rgba(229, 72, 77, .16);
}

.danger-button:hover:not(:disabled) { transform: translateY(-2px); background: var(--danger-dark); }
.danger-button:disabled { cursor: not-allowed; opacity: .38; box-shadow: none; }

.button-count {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 8px;
  font-size: 10px;
}

.topic-list { border-top: 1px solid var(--line); }

.topic-row {
  position: relative;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 70px;
  padding: 13px 24px 13px 38px;
  border-bottom: 1px solid var(--line);
  transition: background .25s, border-color .25s;
}

.topic-row:last-child { border-bottom: 0; }
.topic-row:hover { background: #f8fbff; }
.topic-state { width: 8px; height: 8px; border: 1px solid #b9c6d6; border-radius: 50%; }
.topic-row > div { min-width: 0; }

.topic-row small,
.topic-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-row small { margin-bottom: 3px; color: #96a4b7; font-size: 10px; }
.topic-row strong { color: var(--navy); font-size: 13px; font-weight: 700; }
.topic-order { color: #a1adbd; font: 700 10px/1 var(--display); }
.topic-message { display: none; margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.topic-row.is-processing { background: #f2f8ff; border-color: #cfe4ff; }
.topic-row.is-processing .topic-state { border-color: var(--blue); border-top-color: transparent; animation: spin .7s linear infinite; }
.topic-row.is-processing .topic-message,
.topic-row.is-deleted .topic-message,
.topic-row.is-not-found .topic-message,
.topic-row.is-error .topic-message { display: block; }
.topic-row.is-deleted .topic-state { border-color: var(--green); background: var(--green); }
.topic-row.is-deleted strong { color: var(--success); }
.topic-row.is-not-found .topic-state { border-color: var(--warning); background: var(--warning); }
.topic-row.is-not-found strong { color: var(--warning); }
.topic-row.is-error { background: var(--danger-soft); }
.topic-row.is-error .topic-state { border-color: var(--danger); background: var(--danger); }
.topic-row.is-error strong,
.topic-row.is-error .topic-message { color: #a82c31; }

.result-panel { margin-top: 22px; padding: 34px 38px; scroll-margin-top: 96px; }
.result-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.result-head .eyebrow { margin-bottom: 10px; }
.result-head h2 { margin: 0; color: var(--deep); font: 700 27px/1.2 var(--display); }
.progress-label { color: var(--blue); font: 800 13px/1 var(--display); }
.progress-track { height: 6px; margin-top: 24px; overflow: hidden; border-radius: 999px; background: #e7eef7; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .35s ease; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 26px; }
.summary-grid > div { display: grid; gap: 4px; padding: 18px; border-radius: 13px; background: var(--soft); }
.summary-grid strong { color: var(--deep); font: 700 28px/1 var(--display); }
.summary-grid span { color: var(--muted); font-size: 11px; }
.result-panel > .alert { margin: 24px 0 0; }

.confirmation-dialog {
  width: min(510px, calc(100% - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}

.confirmation-dialog::backdrop { background: rgba(7, 26, 61, .54); backdrop-filter: blur(6px); }
.dialog-card { position: relative; padding: 40px; }

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--white);
  cursor: pointer;
}

.dialog-close:hover { color: var(--ink); background: var(--soft); }
.dialog-kicker { margin: 0 0 10px; color: var(--danger); font: 800 10px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; }
.dialog-card h2 { margin: 0; color: var(--deep); font: 700 31px/1.2 var(--display); }
.dialog-card > p:not(.dialog-kicker) { margin: 12px 0 8px; color: var(--muted); }
.dialog-card code { display: block; padding: 13px; margin-bottom: 26px; overflow: hidden; border-radius: 10px; color: var(--blue); background: var(--soft-blue); font-size: 12px; text-overflow: ellipsis; }
.dialog-card label { display: block; margin-bottom: 9px; color: var(--navy); font-size: 12px; }
.dialog-card label strong { color: var(--danger); font-family: var(--display); }

.dialog-card > input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: var(--white);
  font: 700 14px/1 var(--display);
  letter-spacing: .1em;
}

.dialog-card > input:focus { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(229, 72, 77, .09); }
.dialog-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: 10px; margin-top: 20px; }
.secondary-button { border: 1px solid var(--line); color: var(--navy); background: var(--white); }
.secondary-button:hover { background: var(--soft); }
.operation-running .logout-button { pointer-events: none; opacity: .4; }

@keyframes shell-in { from { opacity: 0; transform: translateY(16px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 960px) {
  .login-shell { grid-template-columns: 1fr; width: min(620px, calc(100% - 32px)); }
  .login-story { min-height: 360px; padding: 38px; }
  .login-story h1 { max-width: 470px; font-size: clamp(38px, 8vw, 52px); }
  .login-panel { min-height: 430px; padding: 58px 38px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .hero-section { grid-template-columns: 1fr; gap: 30px; }
  .hero-aside { max-width: 460px; }
  .topics-card { padding-top: 32px; }
}

@media (max-width: 640px) {
  .login-shell { margin: 16px auto; border-radius: 20px; }
  .login-story { min-height: 330px; padding: 28px 24px; }
  .login-story .underchat-logo { font-size: 24px; }
  .login-story h1 { font-size: 38px; }
  .login-panel { min-height: 390px; padding: 44px 24px; }
  .topbar { height: 68px; padding: 0 16px; }
  .brand-lockup { font-size: 23px; }
  .brand > small,
  .environment-chip,
  .user-chip > span:last-child { display: none; }
  .user-chip { padding-left: 0; border: 0; }
  .dashboard-shell { width: min(100% - 28px, 1240px); padding-top: 48px; }
  .hero-section h1 { font-size: 48px; }
  .control-card { padding: 26px 20px; }
  .topics-card { padding-top: 26px; }
  .section-heading.compact { padding: 0 20px; }
  .topic-row { grid-template-columns: 9px minmax(0, 1fr); padding: 13px 20px; }
  .topic-order { display: none; }
  .topic-row small,
  .topic-row strong { white-space: normal; overflow-wrap: anywhere; }
  .field-meta { display: block; line-height: 1.6; }
  .field-error { display: block; text-align: left; }
  .result-panel { padding: 28px 20px; }
  .result-head { align-items: start; }
  .summary-grid { grid-template-columns: 1fr; }
  .dialog-card { padding: 36px 22px 24px; }
  .dialog-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
