:root {
  --ink: #171813;
  --paper: #f3f0e7;
  --cream: #e8e2d5;
  --lime: #c8f23a;
  --violet: #7557ff;
  --muted: #6d6e66;
  --line: rgba(23, 24, 19, 0.15);
  --display: "Arial Narrow", "Helvetica Neue", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
select { font: inherit; }
button { color: inherit; }
.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; }

.site-header { height: 78px; max-width: 1440px; margin: auto; padding: 0 5vw; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: inherit; font-size: 21px; font-weight: 800; text-decoration: none; letter-spacing: -.04em; }
.brand-mark, .dialog-mark { width: 30px; height: 30px; display: grid; place-items: center; color: var(--paper); background: var(--ink); border-radius: 3px 10px 3px 10px; font: 16px var(--mono); }
nav { display: flex; gap: 34px; }
nav a { padding: 29px 0 25px; color: inherit; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 650; text-decoration: none; }
nav a:hover, nav a.active { border-color: var(--violet); }
.account { min-width: 120px; display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.login-button { padding: 9px 14px; color: white; background: var(--ink); border: 1px solid var(--ink); cursor: pointer; font-size: 12px; font-weight: 750; }
.login-button span { color: var(--lime); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--violet); border-radius: 50%; font: 700 11px var(--mono); }
.account-details { display: grid; font-size: 11px; }
.account-details small { color: var(--muted); }
.logout-button { padding: 4px; color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 10px; text-decoration: underline; text-underline-offset: 3px; }

.market-hero { max-width: 1440px; min-height: 440px; margin: auto; padding: 86px 5vw 70px; position: relative; overflow: hidden; }
.market-hero::before { content: ""; position: absolute; width: 340px; height: 340px; right: 2vw; top: 40px; background: var(--lime); border-radius: 50%; }
.market-hero::after { content: "K"; position: absolute; right: calc(2vw + 82px); top: 67px; color: var(--ink); font: 900 220px/.95 var(--display); transform: rotate(7deg); }
.eyebrow, .section-kicker { position: relative; z-index: 1; margin: 0 0 20px; color: #515249; font: 700 11px var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.eyebrow { display: flex; align-items: center; gap: 10px; }
.eyebrow span { width: 24px; height: 2px; background: var(--violet); }
h1, h2 { position: relative; z-index: 1; margin: 0; font-family: var(--display); font-weight: 850; letter-spacing: -.065em; line-height: .93; text-transform: uppercase; }
h1 { font-size: clamp(58px, 6.5vw, 94px); }
h1 em { color: var(--violet); font-style: normal; }
.market-hero > p:last-child { max-width: 570px; margin: 28px 0 0; position: relative; z-index: 1; color: #505148; font-size: 17px; line-height: 1.65; }

.admin-panel { padding: 64px max(5vw, calc((100vw - 1296px) / 2)); color: white; background: var(--ink); }
.admin-panel .section-kicker { color: var(--lime); }
.admin-heading { display: flex; align-items: end; justify-content: space-between; gap: 40px; }
.admin-heading h2 { color: white; font-size: clamp(36px, 4vw, 54px); }
.admin-heading > p { max-width: 420px; margin: 0; color: #b8b9b1; font-size: 13px; line-height: 1.6; }
.assignment-form { margin-top: 34px; display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 14px; }
.assignment-form label { display: grid; gap: 8px; color: #c8c9c1; font: 700 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.assignment-form select { width: 100%; min-height: 44px; padding: 0 12px; color: var(--ink); background: white; border: 1px solid #66675f; }
.assignment-form button, .assignment-remove { min-height: 44px; padding: 0 18px; color: var(--ink); background: var(--lime); border: 1px solid var(--lime); cursor: pointer; font-size: 11px; font-weight: 800; }
.assignment-form button:disabled, .assignment-remove:disabled { opacity: .5; cursor: wait; }
.assignment-list { margin-top: 28px; display: grid; gap: 8px; }
.assignment-row { padding: 13px 14px; display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 14px; border: 1px solid #474840; }
.assignment-row strong { font-size: 12px; }
.assignment-row span { color: #b8b9b1; font-size: 12px; }
.assignment-remove { min-height: 34px; color: white; background: transparent; border-color: #77786f; }
.admin-empty { margin: 26px 0 0; color: #b8b9b1; font-size: 13px; }

.catalogue { min-height: 600px; padding: 80px max(5vw, calc((100vw - 1296px) / 2)); background: #fffdf6; border-top: 1px solid var(--line); }
.catalogue-heading { display: flex; align-items: end; justify-content: space-between; gap: 40px; }
.section-kicker { margin-bottom: 13px; color: var(--violet); }
h2 { font-size: clamp(40px, 4vw, 62px); }
.view-tabs { display: flex; gap: 8px; }
.view-tabs button { padding: 11px 15px; background: transparent; border: 1px solid var(--line); cursor: pointer; font-size: 12px; font-weight: 700; }
.view-tabs button[aria-selected="true"] { color: white; background: var(--ink); border-color: var(--ink); }
.view-tabs span { min-width: 19px; height: 19px; margin-left: 5px; padding: 2px 5px; display: inline-grid; place-items: center; color: var(--ink); background: var(--lime); border-radius: 10px; font: 9px var(--mono); }
.catalogue-tools { margin: 38px 0 30px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.search { width: min(390px, 100%); height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: white; }
.search span { color: var(--violet); font-size: 20px; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 13px; }
.filters { display: flex; }
.filters button { padding: 8px 14px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font: 700 10px var(--mono); text-transform: uppercase; }
.filters button.selected { color: var(--ink); border-color: var(--violet); }
.notice { margin: -12px 0 20px; padding: 10px 14px; color: #315000; background: #e8f7b9; border-left: 3px solid #7ba000; font-size: 12px; }
.notice.error { color: #7b1a15; background: #fae1df; border-color: #c83b31; }

.template-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.template-card { min-height: 320px; padding: 24px; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); transition: transform 150ms ease, box-shadow 150ms ease; }
.template-card:hover { transform: translateY(-3px); box-shadow: 6px 6px 0 var(--cream); }
.card-top { display: flex; justify-content: space-between; align-items: start; }
.template-icon { width: 48px; height: 48px; display: grid; place-items: center; color: white; background: var(--ink); border-radius: 5px 16px 5px 16px; font: 800 21px var(--mono); }
.price-badge { padding: 6px 9px; border: 1px solid var(--ink); font: 800 9px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.price-badge.free { background: var(--lime); }
.price-badge.premium { color: white; background: var(--violet); }
.price-badge.exclusive { color: white; background: var(--ink); }
.template-card h3 { margin: 32px 0 10px; font-size: 20px; letter-spacing: -.035em; }
.description { min-height: 62px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.meta { margin: 16px 0 20px; color: #8c8d84; font: 9px var(--mono); text-transform: uppercase; }
.template-action { min-height: 43px; margin-top: auto; color: white; background: var(--ink); border: 1px solid var(--ink); cursor: pointer; font-size: 11px; font-weight: 750; }
.template-action:hover { color: var(--ink); background: var(--lime); }
.template-action.added { color: var(--ink); background: transparent; border-color: #8b8c82; }
.template-action:disabled { opacity: .45; cursor: wait; }
.empty { padding: 70px 20px; text-align: center; border: 1px dashed #bbb8ae; }
.empty > span { color: var(--violet); font-size: 40px; }
.empty h3 { margin: 12px 0 5px; }
.empty p { margin: 0; color: var(--muted); font-size: 13px; }

dialog { width: min(440px, calc(100% - 32px)); padding: 42px; color: var(--ink); background: var(--paper); border: 1px solid var(--ink); box-shadow: 10px 10px 0 var(--violet); }
dialog::backdrop { background: rgba(23, 24, 19, .72); }
.dialog-close { position: absolute; top: 12px; right: 14px; background: none; border: 0; cursor: pointer; font-size: 25px; }
.dialog-mark { width: 45px; height: 45px; margin-bottom: 30px; font-size: 21px; }
dialog h2 { font-size: 42px; }
dialog > p:not(.section-kicker, .login-error) { margin: 18px 0 28px; color: var(--muted); font-size: 14px; line-height: 1.6; }
#google-login { min-height: 44px; }
.login-error { padding: 9px; color: #9f2020; background: #fae1df; font-size: 12px; }
dialog small { display: block; margin-top: 18px; color: #85867c; font-size: 10px; }

footer { max-width: 1440px; margin: auto; padding: 34px 5vw; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
footer .brand { color: var(--ink); }

@media (max-width: 900px) {
  .market-hero::before { right: -100px; opacity: .55; }
  .market-hero::after { right: -5px; opacity: .55; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .site-header { height: 66px; }
  nav { display: none; }
  .account-details, .logout-button { display: none; }
  .market-hero { min-height: 390px; padding-top: 65px; }
  .market-hero::before { width: 270px; height: 270px; right: -130px; top: 55px; }
  .market-hero::after { display: none; }
  h1 { font-size: clamp(51px, 15vw, 72px); }
  .market-hero > p:last-child { max-width: 85%; font-size: 15px; }
  .catalogue { padding-top: 60px; padding-bottom: 60px; }
  .catalogue-heading { display: block; }
  .admin-heading { display: block; }
  .admin-heading > p { margin-top: 20px; }
  .assignment-form { grid-template-columns: 1fr; }
  .assignment-row { grid-template-columns: 1fr; }
  .view-tabs { margin-top: 28px; }
  .catalogue-tools { align-items: stretch; flex-direction: column; }
  .filters { align-self: flex-start; }
  .template-grid { grid-template-columns: 1fr; }
  dialog { padding: 34px 25px; }
}

@media (prefers-reduced-motion: reduce) {
  .template-card { transition: none; }
}
