:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #182033;
  --muted: #5f6b7a;
  --line: #d9e0ea;
  --blue: #275fd8;
  --blue-dark: #1f4cae;
  --green: #0f7b68;
  --gold: #b7791f;
  --red: #b42318;
  --shadow: 0 24px 70px rgba(32, 50, 82, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(39, 95, 216, 0.18), transparent 28%),
    radial-gradient(circle at 85% 18%, rgba(15, 123, 104, 0.16), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 46%),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

body.dark {
  --bg: #111827;
  --panel: #172033;
  --ink: #eef4ff;
  --muted: #b9c4d4;
  --line: #2d3a52;
  --blue: #4f8cff;
  --blue-dark: #3975e3;
  --green: #34b89b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

body.dark input,
body.dark select,
body.dark textarea,
body.dark .result-row,
body.dark .history-item,
body.dark .stat-item,
body.dark .live-status span,
body.dark .quick-tools button,
body.dark .file-button,
body.dark .account button,
body.dark .actions button:nth-child(n + 2),
body.dark .history-head button {
  background: #111827;
  color: var(--ink);
}

body.dark .login-badges span {
  background: rgba(17, 24, 39, 0.72);
  border-color: var(--line);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  padding: 10px 14px;
  min-height: 40px;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover {
  background: var(--blue-dark);
  box-shadow: 0 10px 24px rgba(39, 95, 216, 0.18);
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 111, 237, 0.25);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b7c5d8;
}

textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.45;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 1.1fr 420px;
  gap: 24px;
  align-items: center;
}

.brand-panel,
.login-panel,
.tool-panel,
.topbar,
.mode-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-panel {
  min-height: 420px;
  padding: 44px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 24px;
  position: relative;
  overflow: hidden;
}

.brand-panel::after {
  content: "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  position: absolute;
  right: -48px;
  bottom: 24px;
  color: rgba(39, 95, 216, 0.07);
  font-size: 76px;
  font-weight: 900;
  letter-spacing: 0;
  transform: rotate(-8deg);
  white-space: nowrap;
}

.brand-mark {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--green));
  box-shadow: 0 18px 35px rgba(39, 95, 216, 0.24);
  font-size: 56px;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.brand-panel > div {
  position: relative;
  z-index: 1;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 44px;
  line-height: 1.05;
}

.panel-title {
  display: grid;
  gap: 4px;
}

.brand-panel p {
  margin-top: 12px;
  max-width: 520px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.login-badges {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-badges span {
  border: 1px solid #cbd8eb;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 800;
}

.login-panel {
  padding: 24px;
  display: grid;
  gap: 16px;
}

.error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

.success {
  min-height: 20px;
  color: var(--green);
  font-weight: 700;
}

.auth-toggle {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.auth-toggle p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.link-button {
  background: none;
  color: var(--blue);
  padding: 0;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: color 140ms ease;
  min-height: auto;
}

.link-button:hover {
  background: none;
  color: var(--blue-dark);
  box-shadow: none;
  transform: none;
  text-decoration: underline;
}

.hint {
  color: var(--muted);
  font-size: 14px;
}

.topbar {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account span {
  color: var(--muted);
  font-weight: 700;
}

.account button,
.actions button:nth-child(n + 2),
.history-head button {
  color: var(--ink);
  background: #eef2f8;
}

.account button:hover,
.actions button:nth-child(n + 2):hover,
.history-head button:hover {
  background: #e0e7f1;
}

.layout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 18px;
}

.mode-list {
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 8px;
  box-shadow: none;
}

.mode-button {
  width: 100%;
  color: var(--ink);
  background: transparent;
  text-align: left;
  box-shadow: none;
}

.mode-button:hover,
.mode-button.active {
  color: #fff;
  background: var(--blue);
}

.workspace {
  min-width: 0;
}

.tool-panel {
  padding: 18px;
}

.controls,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(160px, 220px) 1fr;
  gap: 14px;
  align-items: end;
}

.quick-tools {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-tools button,
.file-button {
  min-height: 40px;
  border-radius: 8px;
  color: var(--ink);
  background: #eef2f8;
  padding: 10px 13px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.quick-tools button:hover,
.file-button:hover {
  background: #e0e7f1;
  box-shadow: none;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.text-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.live-status {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.live-status span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 800;
}

.live-status span:empty {
  display: none;
}

.results-list,
.history-list,
.stats-grid,
.frequency-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.result-row,
.history-item,
.stat-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 12px;
}

.result-row strong,
.history-item strong,
.stat-item strong {
  display: block;
  margin-bottom: 6px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.stat-item span {
  color: var(--blue);
  font-size: 28px;
  font-weight: 800;
}

.frequency-list {
  margin-top: 18px;
}

.frequency-row {
  display: grid;
  grid-template-columns: 44px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.frequency-row strong,
.frequency-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.frequency-row span {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef7;
}

.frequency-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

@media (max-width: 850px) {
  .auth-view,
  .layout,
  .text-grid,
  .controls,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: auto;
    padding: 28px;
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 34px;
  }

  .mode-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar,
  .history-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 16px, 1180px);
    padding: 8px 0;
  }

  .mode-list,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 76px;
    height: 76px;
    font-size: 44px;
  }
}
