:root {
  color-scheme: dark;
  --background: #07090c;
  --surface: #11151a;
  --surface-strong: #171c22;
  --surface-soft: #0c1014;
  --text: #f5f7fa;
  --muted: #99a3b3;
  --blue: #3d9cff;
  --blue-strong: #1379dc;
  --border: #27303a;
  --danger: #ff7b86;
  --success: #62d49a;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .28);
  --focus: 0 0 0 4px rgba(61, 156, 255, .25);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -10%, rgba(61, 156, 255, .11), transparent 28rem),
    var(--background);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.65rem); line-height: 1.05; letter-spacing: -.045em; }
h2 { font-size: clamp(1.55rem, 2.3vw, 2.15rem); line-height: 1.15; letter-spacing: -.03em; }
h3 { font-size: 1.25rem; line-height: 1.25; }

.container { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.site-header {
  width: min(1280px, calc(100% - 40px));
  min-height: 88px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(39, 48, 58, .65);
}
.brand { display: inline-flex; width: clamp(168px, 19vw, 235px); text-decoration: none; }
.brand img { width: 100%; height: auto; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.admin-name { color: var(--muted); font-size: .92rem; }

.panel {
  background: linear-gradient(145deg, rgba(23, 28, 34, .96), rgba(14, 18, 23, .98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.section-heading { max-width: 760px; margin-bottom: 30px; }
.section-heading h1, .section-heading h2 { margin-bottom: 12px; }
.section-heading > p:not(.eyebrow) { color: var(--muted); font-size: 1.06rem; }
.eyebrow {
  margin-bottom: 10px;
  color: var(--blue);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.button {
  min-height: 46px;
  padding: 11px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.15;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible { outline: none; box-shadow: var(--focus); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { background: var(--blue); color: #03101e; }
.button-primary:hover { background: #62afff; }
.button-secondary { background: var(--surface-soft); border-color: var(--border); color: var(--text); }
.button-secondary:hover { border-color: #445262; }
.button-danger { background: rgba(255, 123, 134, .1); border-color: rgba(255, 123, 134, .42); color: #ffc3c8; }
.button-danger:hover { background: rgba(255, 123, 134, .18); border-color: var(--danger); }
.button-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.button-wide { width: 100%; min-height: 54px; font-size: 1rem; }

label { color: #dfe5ed; font-weight: 750; }
input, textarea {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--surface-soft);
  color: var(--text);
}
input::placeholder { color: #737e8d; }
textarea { min-height: 112px; resize: vertical; }
textarea::placeholder { color: #737e8d; }
.form-stack { display: grid; gap: 12px; }
.form-stack label:not(:first-of-type) { margin-top: 8px; }
.field-error { margin: -4px 0 0; color: var(--danger); font-size: .86rem; }
.notice { padding: 13px 15px; margin-bottom: 18px; border: 1px solid; border-radius: 12px; }
.notice-error { border-color: rgba(255, 123, 134, .4); background: rgba(255, 123, 134, .08); color: #ffc3c8; }
.notice-success { border-color: rgba(98, 212, 154, .35); background: rgba(98, 212, 154, .08); color: #baf2d3; }

.centered-page { display: grid; place-items: center; padding: 28px 20px; }
.auth-shell { width: min(500px, 100%); }
.auth-panel { padding: clamp(28px, 6vw, 48px); }
.auth-panel .brand { margin: 0 auto 42px; }
.auth-panel h1 { font-size: 2.25rem; }

.admin-page { padding-block: 48px 96px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 28px; }
.metric-card { padding: 30px; display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.metric-card strong { color: var(--blue); font-size: clamp(2.2rem, 5vw, 3.5rem); line-height: 1; }
.metric-card span { color: var(--muted); }
.creation-panel { padding: clamp(24px, 5vw, 42px); margin-bottom: 64px; }
.creation-form { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.field-group { display: grid; gap: 8px; align-content: start; }
.field-span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; }
.slug-input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.slug-input:focus-within { box-shadow: var(--focus); }
.slug-input span { padding-left: 14px; color: var(--muted); }
.slug-input input { border: 0; box-shadow: none !important; padding-left: 3px; }
.resource-section > .section-heading { margin-bottom: 20px; }
.resource-list { display: grid; gap: 18px; }
.resource-card { padding: clamp(22px, 3.5vw, 32px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.resource-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding-bottom: 24px; }
.resource-main h3 { margin-bottom: 7px; }
.slug-link { color: var(--blue); text-decoration: none; }
.resource-description { max-width: 760px; margin: 14px 0 0; color: #cbd3de; }
.resource-url, .resource-date { color: var(--muted); margin: 6px 0 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.click-count { min-width: 94px; padding: 14px; display: grid; place-content: center; text-align: center; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 14px; }
.click-count strong { font-size: 1.85rem; line-height: 1; }
.click-count span { margin-top: 5px; color: var(--muted); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; }
.resource-actions { padding-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--border); }
.delete-resource-trigger { margin-left: auto; }
.edit-resource { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.edit-resource summary { width: fit-content; color: var(--blue); cursor: pointer; font-weight: 750; }
.edit-form { max-width: 780px; margin-top: 20px; display: grid; gap: 16px; }
.immutable-note { margin: 0; color: var(--muted); font-size: .84rem; }
.edit-form .button { width: fit-content; }
.delete-dialog {
  width: min(540px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 28px 100px rgba(0, 0, 0, .65);
}
.delete-dialog::backdrop { background: rgba(0, 0, 0, .74); backdrop-filter: blur(4px); }
.delete-dialog-content { padding: clamp(24px, 5vw, 38px); }
.delete-dialog h2 { margin-bottom: 14px; }
.delete-dialog-content > p:not(.eyebrow) { color: #cbd3de; }
.delete-dialog-actions { margin-top: 28px; display: flex; justify-content: flex-end; gap: 10px; }

.public-header { border-bottom-color: transparent; }
.hero { max-width: 820px; padding: 76px 0 52px; }
.hero h1 { margin-bottom: 20px; }
.hero > p:not(.eyebrow) { max-width: 650px; color: var(--muted); font-size: 1.13rem; }
.list-page { padding-bottom: 100px; }
.list-rows { display: grid; gap: 14px; }
.list-row { min-height: 132px; padding: 24px 26px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.list-row h2 { margin-bottom: 7px; font-size: 1.35rem; }
.list-row p { margin-bottom: 0; color: var(--muted); }
.list-row .resource-icon { margin-bottom: 0; }
.list-row .button { min-width: 150px; }
.resource-icon { width: 48px; height: 48px; margin-bottom: 26px; display: grid; place-items: center; border-radius: 14px; background: rgba(61, 156, 255, .13); color: var(--blue); font-weight: 900; }
.empty-state { grid-column: 1 / -1; padding: 50px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.resource-shell { width: min(760px, calc(100% - 40px)); margin: 56px auto 96px; }
.preview-badge { width: fit-content; margin: 0 auto 18px; padding: 7px 12px; color: #b9ddff; background: rgba(61, 156, 255, .12); border: 1px solid rgba(61, 156, 255, .28); border-radius: 999px; font-size: .8rem; }
.unlock-panel { padding: clamp(26px, 7vw, 56px); }
.unlock-panel .section-heading { margin-bottom: 34px; }
.unlock-panel h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.resource-lead-description { color: #d7dee7 !important; font-size: 1.08rem !important; }
.course-invitation { margin-top: 24px; color: var(--text); }
.course-invitation p { margin-bottom: 12px; color: var(--text); }
.course-invitation p:last-child { margin-bottom: 0; }
.course-invitation a { color: var(--text); font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.course-invitation a:hover, .course-invitation a:focus-visible { color: var(--blue); }
.privacy-note { margin: 6px auto 0; max-width: 580px; color: #7f8997; text-align: center; font-size: .82rem; }
.unlock-success { text-align: center; }
.success-icon { width: 58px; height: 58px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 50%; background: rgba(98, 212, 154, .13); color: var(--success); font-size: 1.5rem; font-weight: 900; }
.unlock-success p { color: var(--muted); }
.unlock-success .button { margin-top: 14px; }
.discover-button { width: 100%; margin-top: 16px; }
.not-found { width: min(580px, 100%); padding: 48px; text-align: center; }
.not-found .brand { margin: 0 auto 42px; }
.not-found p:not(.eyebrow) { color: var(--muted); }

@media (max-width: 720px) {
  .container, .site-header, .resource-shell { width: min(100% - 28px, 1180px); }
  .site-header { min-height: 74px; }
  .brand { width: 150px; }
  .admin-name { display: none; }
  .admin-page { padding-block: 28px 64px; }
  .metric-grid, .creation-form { grid-template-columns: 1fr; }
  .metric-card { padding: 22px; }
  .creation-panel { margin-bottom: 48px; }
  .field-span-2 { grid-column: auto; }
  .form-actions .button { width: 100%; }
  .resource-main { grid-template-columns: 1fr; }
  .click-count { min-width: 0; grid-template-columns: auto auto; gap: 6px; justify-content: start; align-items: baseline; text-align: left; }
  .click-count strong { font-size: 1.4rem; }
  .resource-actions { display: grid; }
  .resource-actions .button { width: 100%; }
  .delete-resource-trigger { margin-left: 0; }
  .delete-dialog-actions { display: grid; }
  .delete-dialog-actions .button { width: 100%; }
  .hero { padding: 52px 0 36px; }
  .list-row { grid-template-columns: 1fr; gap: 16px; align-items: start; }
  .list-row .button { width: 100%; }
  .edit-form .button { width: 100%; }
  .resource-shell { margin-block: 28px 64px; }
}

@media (max-width: 430px) {
  .header-actions .button { min-height: 42px; padding-inline: 13px; }
  .public-header .button { font-size: .85rem; }
  .unlock-panel, .auth-panel, .not-found { padding: 24px; }
  .resource-card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
