/* ==========================
   Theme tokens
   ========================== */
:root {
  --bg: #f5f7fb;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #cfe6ff33, transparent 60%),
    radial-gradient(1200px 600px at 90% 110%, #c4f1ff33, transparent 60%),
    linear-gradient(180deg, #fff 0%, #f6f8fb 100%);
  --panel: #ffffffcc;
  --panel-border: #d0d7deaa;
  --fg: #0f172a;
  --muted: #6b7280;
  --accent: #0a7aff;
  --accent-2: #4cbfff;
  --accent-focus: #0059c8;
  --header-text-grad: linear-gradient(90deg, var(--accent), var(--accent-2));
  --shadow: 0 8px 24px rgba(2, 6, 23, .08);
  --kbd-bg: #f3f4f6;
  --kbd-border: #e5e7eb;
  --table-hover: rgba(2, 6, 23, 0.04);
}

:root[data-theme="dark"] {
  --bg: #0a0f1a;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #1e3a8a33, transparent 60%),
    radial-gradient(1200px 600px at 90% 110%, #0ea5a733, transparent 60%),
    linear-gradient(180deg, #0a0f1a 0%, #0b1220 100%);
  --panel: #0b1628cc;
  --panel-border: #274060aa;
  --fg: #e5e7eb;
  --muted: #93a3b8;
  --accent: #4c8dff;
  --accent-2: #22d3ee;
  --accent-focus: #7aa3ff;
  --header-text-grad: linear-gradient(90deg, #93c5fd, #22d3ee);
  --shadow: 0 10px 30px rgba(2, 6, 23, .55);
  --kbd-bg: #0f1624;
  --kbd-border: #273248;
  --table-hover: rgba(255, 255, 255, 0.05);
}

/* Layout */
* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: system-ui, Segoe UI, Roboto, Inter, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  background-image: var(--bg-grad);
  transition: background-color .25s ease, color .25s ease, background-image .35s ease;
  padding: 24px;
}

.container {
  max-width: 1100px;
  margin: 0 auto
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem);
  line-height: 1.2;
  background: var(--header-text-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--muted);
  margin: .25rem 0 .75rem
}

/* Panels & inputs */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-bottom: 1rem;
  padding: 1rem;
}

/* Inputs & selects */
input,
select,
textarea {
  padding: .45rem .6rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: .9rem;
  font-family: inherit;
}

select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%236b7280' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  padding-right: 1.8rem;
}

select option {
  background: var(--bg);
  color: var(--fg);
}

/* Buttons */
button {
  padding: .5rem .7rem;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease, background-color .2s ease;
}

button:hover {
  transform: translateY(-1px)
}

button:active {
  transform: translateY(0)
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent)
}

button.primary:hover {
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 35%, transparent)
}

button.icon {
  padding: .4rem .55rem
}

button svg {
  width: 18px;
  height: 18px;
  display: block
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0
}

/* Back navigation link */
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  padding: .3rem;
  border-radius: 8px;
  transition: color .2s ease, background .2s ease
}

.back-link:hover {
  color: var(--fg);
  background: var(--table-hover)
}

/* Theme toggle animation */
#themeToggle.twirl {
  animation: twirl .45s ease
}

@keyframes twirl {
  0% {
    transform: rotate(0) scale(1)
  }

  50% {
    transform: rotate(180deg) scale(1.15)
  }

  100% {
    transform: rotate(360deg) scale(1)
  }
}

/* Footer styling */
.footer {
  margin-top: 2rem;
  padding: 1.5rem 0.75rem;
  text-align: center;
}

.attribution {
  color: var(--muted);
  font-size: 0.9rem;
}

.attribution a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

.attribution a:hover {
  color: var(--accent-focus);
  text-decoration: underline;
}

/* Decorative corner SVG (subtle) */
.decoration {
  position: absolute;
  inset: auto 0 0 auto;
  right: 24px;
  bottom: 24px;
  opacity: .15;
  pointer-events: none
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  animation: fadeIn 0.2s forwards;
}

.modal-container {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 90%;
  max-width: 1200px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  animation: scaleIn 0.2s forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--panel-border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--fg);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-body textarea {
  width: 100%;
  height: 100%;
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  padding: 1rem;
  background: var(--kbd-bg);
  color: var(--fg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--panel-border);
  background: var(--table-hover);
  border-radius: 0 0 12px 12px;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  to {
    transform: scale(1);
  }
}