:root {
  --app-bg: #f4f7fb;
  --card-bg: rgba(255,255,255,.95);
  --card-border: rgba(15,23,42,.08);
  --text-muted: #667085;
  --header-bg: rgba(255,255,255,.92);
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --soft-shadow: 0 12px 30px rgba(15,23,42,.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --app-bg: #0b1120;
    --card-bg: rgba(17,24,39,.95);
    --card-border: rgba(255,255,255,.08);
    --text-muted: #94a3b8;
    --header-bg: rgba(11,17,32,.92);
    --code-bg: #020617;
    --code-text: #e2e8f0;
    --soft-shadow: 0 12px 30px rgba(0,0,0,.18);
  }
}

html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(13,110,253,.09), transparent 28rem),
    radial-gradient(circle at 100% 15%, rgba(111,66,193,.07), transparent 24rem),
    var(--app-bg);
}

.app-shell { max-width: 1520px; }
.min-w-0 { min-width: 0; }

.app-header {
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
  z-index: 1025;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #0d6efd, #6f42c1);
  box-shadow: 0 8px 22px rgba(13,110,253,.25);
  flex: 0 0 auto;
}

.language-select { width: auto; max-width: 210px; }
.tool-nav-wrap { overflow: hidden; }
.tool-nav {
  overflow-x: auto;
  gap: .45rem;
  padding: .35rem;
  border-radius: 16px;
  background: rgba(127,127,127,.06);
  scrollbar-width: thin;
}
.tool-nav .nav-link {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border-radius: 12px;
  min-height: 42px;
}

.tool-card {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  box-shadow: var(--soft-shadow);
  border-radius: 18px;
}
.tool-card .card-body { padding: 1.1rem; }

.section-heading p { color: var(--text-muted); margin-bottom: 0; font-size: .92rem; }
.form-text, .text-secondary { color: var(--text-muted) !important; }

.code-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .84rem;
  line-height: 1.45;
  tab-size: 2;
}
.key-area { min-height: 190px; }
.data-area { min-height: 150px; }
.compact-area { min-height: 120px; }
.tall-area { min-height: 320px; }

textarea.code-area:focus {
  box-shadow: 0 0 0 .2rem rgba(13,110,253,.11);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.action-btn { min-height: 46px; font-weight: 600; }
.compact-select { width: auto; max-width: 270px; }

.verify-result {
  border: 1px dashed var(--card-border);
  border-radius: 14px;
  min-height: 90px;
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
}
.verify-result.valid {
  border-style: solid;
  border-color: rgba(25,135,84,.38);
  background: rgba(25,135,84,.08);
  color: #198754;
}
.verify-result.invalid {
  border-style: solid;
  border-color: rgba(220,53,69,.38);
  background: rgba(220,53,69,.08);
  color: #dc3545;
}

.key-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: .75rem;
}
.key-details.empty-state {
  min-height: 180px;
  place-items: center;
  align-content: center;
  grid-template-columns: 1fr;
  color: var(--text-muted);
  text-align: center;
}
.detail-item {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: .75rem;
  min-width: 0;
}
.detail-item .label { font-size: .75rem; color: var(--text-muted); margin-bottom: .15rem; }
.detail-item .value { word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.detail-item.full { grid-column: 1 / -1; }

.tech-details {
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: rgba(127,127,127,.045);
  overflow: hidden;
}
.tech-details summary {
  cursor: pointer;
  padding: .9rem 1rem;
  user-select: none;
  font-weight: 600;
}
.tech-content { padding: 0 1rem 1rem; }

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: var(--app-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
}

.busy .action-btn, button.busy { pointer-events: none; opacity: .65; }

@media (max-width: 767.98px) {
  .app-shell { padding-left: .75rem; padding-right: .75rem; }
  .app-header .brand-icon { width: 38px; height: 38px; border-radius: 12px; }
  .language-select { width: 154px; max-width: 42vw; }
  .tool-card { border-radius: 15px; }
  .tool-card .card-body { padding: .9rem; }
  .tool-nav { margin-left: -.25rem; margin-right: -.25rem; border-radius: 13px; }
  .tool-nav .nav-link { padding: .58rem .7rem; }
  .tool-nav .nav-link span { font-size: .88rem; }
  .key-area { min-height: 150px; }
  .data-area { min-height: 130px; }
  .tall-area { min-height: 240px; }
  .key-details { grid-template-columns: 1fr; }
  .detail-item.full { grid-column: auto; }
  .button-row > .btn, .button-row > .file-label { flex: 1 1 auto; }
  .compact-select { width: 100%; max-width: none; }
}

@media (max-width: 420px) {
  .app-header h1 { font-size: 1.05rem; }
  .language-select { width: 145px; }
  .tool-nav .nav-link i { display: none; }
}
