:root {
  color-scheme: dark;
  --bg: #050408;
  --panel: #141119;
  --panel-soft: #100d13;
  --line: #2b2633;
  --line-strong: #3a3344;
  --text: #f4f1f6;
  --muted: #8c8494;
  --muted-soft: #625b6b;
  --accent: #ed7a35;
  --accent-soft: #2b1612;
  --danger: #ff7070;
  --ok: #5fd28d;
  --upload-card-width: 560px;
  --upload-card-padding: 20px;
  --drop-zone-height: 160px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { color: #ff9658; }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(100% - 48px, 1400px);
  height: 64px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 18px;
}

nav a {
  color: var(--accent);
  font-weight: 700;
}

nav a:hover {
  color: #ff9658;
}

.language-switch {
  position: relative;
  color: var(--accent);
}

.language-trigger {
  display: flex;
  width: 92px;
  height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.language-trigger::-webkit-details-marker {
  display: none;
}

.language-trigger:hover,
.language-switch[open] .language-trigger {
  background: transparent;
}

.language-globe-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.language-code {
  min-width: 24px;
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
  text-align: center;
}

.language-caret {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.82;
  transform: translateY(-2px) rotate(45deg);
}

.language-switch[open] .language-caret {
  transform: translateY(2px) rotate(225deg);
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 256px;
  padding: 8px;
  border: 1px solid rgba(244, 241, 246, 0.08);
  border-radius: 14px;
  background: #0e0c12;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.language-option {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-radius: 10px;
  color: #aaa4b4;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
}

.language-option:hover {
  background: rgba(244, 241, 246, 0.05);
  color: var(--text);
}

.language-option.is-current {
  background: #26242b;
  color: var(--text);
}

.language-check {
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.shell {
  width: min(100% - 48px, 1400px);
  min-height: calc(100vh - 64px);
  margin: 0 auto;
  padding: 44px 0 72px;
}

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

h1 {
  margin-bottom: 12px;
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  margin: 32px 0 12px;
  font-size: 18px;
  line-height: 1.25;
}

.upload-hero {
  display: flex;
  min-height: calc(100vh - 180px);
  align-items: center;
  flex-direction: column;
  text-align: center;
}

.upload-hero h1 {
  margin-bottom: 10px;
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
}

.text-accent {
  color: var(--accent);
}

.hero-sub {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.hero-copy {
  margin-bottom: 58px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.35;
}

.upload-card {
  display: grid;
  width: min(100%, var(--upload-card-width));
  margin: 0 auto;
  padding: var(--upload-card-padding);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.drop-zone {
  display: flex;
  width: 100%;
  min-height: var(--drop-zone-height);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 28px 20px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: var(--panel-soft);
  cursor: pointer;
  gap: 10px;
}

.drop-zone.is-dragging,
.drop-zone:focus-within {
  border-color: var(--accent);
  background: #130f14;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.drop-cloud-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.drop-cloud-icon svg {
  width: 44px;
  height: 44px;
}

.drop-title {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
}

.browse-button {
  display: flex;
  width: 100%;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent);
  color: #1c0d05;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.file-name {
  display: block;
  width: min(100%, 360px);
  min-height: 20px;
  margin-top: 14px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.primary-button {
  width: 100%;
}

.upload-meta {
  margin: 0;
  color: var(--muted-soft);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.apply-key-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, var(--upload-card-width));
  margin: 20px auto 0;
  padding: 20px;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  text-align: left;
}

.apply-key-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.apply-key-icon {
  display: grid;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(237, 122, 53, 0.2);
}

.apply-key-icon svg {
  width: 28px;
  height: 28px;
}

.apply-key-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.apply-key-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.apply-key-btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0 22px;
  border-radius: 10px;
  background: var(--accent);
  color: #1c0d05;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.apply-key-btn:hover {
  color: #1c0d05;
  background: #ff9658;
}

.apply-key-page {
  max-width: 760px;
  margin: 0 auto;
}

.contact-card,
.disclaimer-card {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.contact-card h2,
.disclaimer-card h2 {
  margin-top: 0;
}

.contact-card p:last-child,
.disclaimer-card p:last-child {
  margin-bottom: 0;
}

.key-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 8px;
  gap: 8px;
  text-align: center;
}

.key-icon-wrap {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  box-shadow: 0 12px 32px rgba(237, 122, 53, 0.25);
}

.key-icon-wrap svg {
  width: 26px;
  height: 26px;
}

.key-entry-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}

.key-entry-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.key-entry-row {
  display: flex;
  width: 100%;
  margin-top: 8px;
  gap: 10px;
}

.key-entry-row input {
  flex: 1;
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 28px;
}

.panel > h2:first-child {
  margin-top: 0;
}

.cards {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.cards > * {
  min-width: 0;
  overflow-x: auto;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  max-width: 520px;
  gap: 16px;
}

.toolbar {
  display: flex;
  margin: 18px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 32px;
  padding: 48px 0 0;
}

.auth-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

.key-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.key-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  pointer-events: none;
}

.key-input-wrap input {
  width: 320px;
  padding-left: 40px;
}

input,
select,
button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d0b11;
  color: var(--text);
  font: inherit;
}

input,
select {
  padding: 0 14px;
}

input::placeholder {
  color: var(--muted-soft);
}

input[type="file"] {
  width: 100%;
}

button {
  padding: 0 18px;
  border-color: var(--accent);
  background: var(--accent);
  color: #1c0d05;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.06);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(237, 122, 53, 0.72);
  outline-offset: 3px;
}

table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--text);
  font-weight: 750;
  white-space: nowrap;
}

td {
  color: #e8e3ee;
}

td input {
  width: 100%;
}

td button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}

td form {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

/* Pages card — nowrap on compact columns only */
#pagesCard table td:nth-child(5),
#pagesCard table td:nth-child(6),
#pagesCard table td:nth-child(7) { white-space: nowrap; }

/* Admin card — nowrap on compact columns only */
#adminCard table td:nth-child(3),
#adminCard table td:nth-child(4),
#adminCard table td:nth-child(6) { white-space: nowrap; }

code {
  color: var(--muted);
  word-break: break-all;
}

.message {
  width: 100%;
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20, 17, 25, 0.96);
  text-align: left;
}

.message.error {
  border-color: var(--danger);
  color: var(--danger);
}

.message.success {
  border-color: var(--ok);
  color: var(--ok);
}

@media (max-width: 720px) {
  :root {
    --upload-card-padding: 16px;
    --drop-zone-height: 140px;
  }

  .topbar,
  .shell {
    width: min(100% - 28px, 1400px);
  }

  .topbar {
    height: auto;
    min-height: 60px;
    gap: 12px;
  }

  nav {
    gap: 12px;
  }

  .language-trigger {
    width: 92px;
    height: 40px;
    border-radius: 12px;
  }

  .language-menu {
    min-width: min(256px, calc(100vw - 28px));
  }

  .shell {
    min-height: calc(100vh - 60px);
    padding: 30px 0 54px;
  }

  .upload-hero {
    min-height: auto;
  }

  .upload-card {
    border-radius: 14px;
  }

  .drop-zone {
    border-radius: 10px;
  }

  .panel {
    padding: 18px;
    overflow-x: auto;
  }
}
