:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --panel: rgba(15, 23, 42, 0.72);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22d3ee;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #1d4ed8, var(--bg) 45%);
  min-height: 100vh;
}

.page-wrap { width: min(1100px, 94vw); margin: 2rem auto; position: relative; z-index: 2; }
.glass {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 60px rgba(2, 6, 23, .35);
}
.site-header {
  padding: .85rem 1rem;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.brand { color: white; text-decoration: none; font-weight: 700; }
.top-nav { display: flex; gap: .5rem; flex-wrap: wrap; }
a {
  color: var(--accent);
  text-decoration: none;
  transition: color .2s ease;
}
a:hover { color: white; }

.link-button {
  width: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 400;
}
.link-button:hover { color: white; box-shadow: none; transform: none; }

.inline-form { display: inline; }

.main-card { padding: 1.25rem; animation: fadeIn .4s ease; }
h1, h2, h3 { margin-top: .4rem; margin-bottom: .8rem; }
p { color: var(--muted); }

section + section, .card + .card, form + form { margin-top: 1rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.card { padding: 1rem; border-radius: 14px; background: rgba(30, 41, 59, .75); border: 1px solid rgba(148, 163, 184, .2); }

input, textarea, select, button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, .35);
  padding: .65rem .75rem;
  font: inherit;
}
input, textarea, select { background: rgba(15, 23, 42, .7); color: var(--text); }
textarea { min-height: 100px; resize: vertical; }

button {
  cursor: pointer;
  background: linear-gradient(120deg, #0ea5e9, #22d3ee);
  color: #082f49;
  border: none;
  font-weight: 700;
  transition: transform .18s ease, box-shadow .2s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(34, 211, 238, .3); }
button:active { transform: translateY(0); }
button.danger { background: linear-gradient(120deg, #f43f5e, #fb7185); color: white; }
button.subtle { background: rgba(71, 85, 105, .65); color: var(--text); }

.helptext, ul.errorlist { color: var(--warning); font-size: .88rem; margin: .2rem 0 .45rem; }
ul { padding-left: 1.2rem; }
.file-list li { margin-bottom: .5rem; }

.messages { display: grid; gap: .5rem; margin-bottom: 1rem; }
.message { padding: .75rem .9rem; display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.message.success { border-color: rgba(52, 211, 153, .5); }
.message.error { border-color: rgba(251, 113, 133, .5); }
.message.warning { border-color: rgba(251, 191, 36, .5); }
.icon-btn { width: auto; padding: .2rem .5rem; background: transparent; color: var(--muted); }

pre.result-box {
  white-space: pre-wrap;
  word-break: break-word;
  padding: .9rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, .8);
  border: 1px solid rgba(148, 163, 184, .2);
  margin: 0;
}
.action-row { display: flex; gap: .5rem; margin-top: .55rem; }
.action-row > * { width: auto; }
.button-link {
  display: inline-block;
  border-radius: 10px;
  padding: .65rem .75rem;
  background: linear-gradient(120deg, #0ea5e9, #22d3ee);
  color: #082f49;
  font-weight: 700;
}
.button-link:hover { color: #082f49; }

.bg-orb {
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: .32;
  z-index: 1;
}
.orb-1 { background: #14b8a6; top: -60px; left: -40px; }
.orb-2 { background: #2563eb; bottom: -80px; right: -40px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .page-wrap { margin: 1rem auto; }
  .site-header { flex-direction: column; align-items: flex-start; }
}

.tools-inline-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-panel-wrapper {
  animation: fadeIn .4s ease;
}

.tool-panel-header {
  padding: .65rem 1rem;
  margin-bottom: .5rem;
  border-radius: 14px;
}

.tool-panel-header h2 {
  margin: 0;
}

.tool-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 800px) {
  .tool-panel-grid {
    grid-template-columns: 1fr;
  }
}

/* Data tables (keys & results on dashboard) */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-top: .5rem;
}
.data-table th {
  text-align: left;
  padding: .5rem .6rem;
  color: var(--muted);
  border-bottom: 1px solid rgba(148, 163, 184, .25);
}
.data-table td {
  padding: .5rem .6rem;
  border-bottom: 1px solid rgba(148, 163, 184, .1);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.truncate { display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.gallery-image {
  max-width: min(100%, 320px);
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, .25);
  margin-top: .5rem;
}

/* Save notices in tool results */
.save-notice {
  color: var(--success);
  font-size: .88rem;
  margin: .3rem 0 0;
}

/* Danger button variant for subtle contexts */
button.subtle.danger { background: rgba(251, 113, 133, .2); color: var(--danger); }
button.subtle.danger:hover { background: rgba(251, 113, 133, .4); }
