@import url("https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700;800&display=swap");

:root {
  --blue: #1a227e;
  --green: #00cb8a;
  --deep: #001238;
  --ink: #10172f;
  --muted: #5f6988;
  --line: #dce2ef;
  --soft: #f5f8fb;
  --white: #ffffff;
  --danger: #b42318;
  --shadow: 0 24px 60px rgba(0, 18, 56, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #f7fbff 0%, #eef6f4 100%);
  font-family: Rubik, Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.home-shell,
.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.home-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
}

.home-hero {
  max-width: 760px;
  padding: 72px 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  color: var(--deep);
  font-size: clamp(2.3rem, 5vw, 4.9rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lead,
.page-title p {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 34px;
}

.primary-link,
.secondary-link,
.generate-button,
.download-button,
.password-row button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
}

.primary-link,
.generate-button,
.password-row button {
  color: var(--white);
  background: var(--blue);
}

.secondary-link,
.download-button {
  color: var(--deep);
  background: var(--green);
}

.download-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 18, 56, 0.82);
}

.auth-gate.is-open {
  display: grid;
}

.auth-gate.is-hidden {
  display: none;
}

.auth-panel,
.control-panel,
.result-panel {
  border: 1px solid rgba(220, 226, 239, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(460px, 100%);
  padding: 32px;
}

.auth-panel h1 {
  font-size: 2rem;
  line-height: 1.12;
}

.auth-panel label,
.control-panel label {
  display: grid;
  gap: 8px;
  color: var(--deep);
  font-size: 0.9rem;
  font-weight: 700;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--white);
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(0, 203, 138, 0.36);
  outline-offset: 2px;
}

.form-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.app-shell {
  padding: 20px 0 40px;
}

.app-shell.is-locked {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand-word {
  color: var(--blue);
  font-size: 1.35rem;
  font-weight: 800;
}

.nav-links {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.nav-links a {
  min-height: 36px;
  border-radius: 7px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.nav-links a.is-active {
  color: var(--white);
  background: var(--blue);
}

.page-title {
  max-width: 860px;
  padding: 42px 0 28px;
}

.page-title h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 390px) 1fr;
  gap: 20px;
  align-items: start;
}

.control-panel,
.result-panel {
  padding: 22px;
}

fieldset {
  margin: 0 0 18px;
  border: 0;
  padding: 0;
}

legend {
  margin-bottom: 8px;
  color: var(--deep);
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented label {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--soft);
  font-weight: 700;
}

.segmented input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: 0 0 18px;
  accent-color: var(--blue);
}

.control-panel.source-random .source-upload-only,
.control-panel.source-upload .source-random-only {
  display: none;
}

.source-upload-only {
  display: none;
}

.control-panel.source-upload .source-upload-only,
.control-panel:has(input[name="source"][value="upload"]:checked) .source-upload-only {
  display: grid;
}

.control-panel:has(input[name="source"][value="random"]:checked) .source-upload-only,
.control-panel:has(input[name="source"][value="upload"]:checked) .source-random-only {
  display: none;
}

.control-panel.source-upload .source-row,
.control-panel:has(input[name="source"][value="upload"]:checked) .source-row {
  grid-template-columns: 1fr;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.upload-area {
  margin-bottom: 20px;
}

.generate-button {
  width: 100%;
}

.result-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.result-heading h2 {
  margin-bottom: 0;
  color: var(--deep);
  font-size: 1.35rem;
  line-height: 1.25;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.metrics div {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.metrics dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metrics dd {
  margin: 8px 0 0;
  color: var(--deep);
  font-size: 1.15rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.notes {
  margin: 0 0 18px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.preview {
  min-height: 260px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
  color: #172039;
  background: #fbfdff;
  font-family: "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre;
}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .result-heading,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
  }

  .nav-links a {
    flex: 1;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .home-shell,
  .app-shell {
    width: min(100% - 22px, 1180px);
  }

  .grid-2,
  .segmented,
  .metrics,
  .password-row {
    grid-template-columns: 1fr;
  }

  .home-actions a {
    width: 100%;
  }

  .auth-panel,
  .control-panel,
  .result-panel {
    padding: 18px;
  }
}
