:root {
  color-scheme: light dark;

  --orange-500: #ef6c37;
  --orange-600: #d6552a;
  --orange-100: #fbdfcc;
  --ink-900: #241a14;
  --ink-600: #7a6a5c;
  --paper-0: #fffdfb;
  --paper-50: #f7efe7;
  --line: #e7d9c9;
  --danger: #c23b1f;

  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --orange-500: #ff7a42;
    --orange-600: #ff9463;
    --orange-100: #4a2c1c;
    --ink-900: #f5e9dd;
    --ink-600: #b7a08d;
    --paper-0: #1b140f;
    --paper-50: #241a13;
    --line: #3a2c22;
    --danger: #ff6b52;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink-900);
  background: var(--paper-0);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* header */

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink-900);
}

.brand-mark {
  position: relative;
  width: 2rem;
  height: 2rem;
  flex: none;
}

.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.brand-mark-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--orange-500);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  border-radius: 7px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.brand-name em {
  font-family: var(--font-body);
  font-weight: 500;
  font-style: normal;
  font-size: 0.8rem;
  color: var(--ink-600);
}

.site-nav { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
.site-nav a { text-decoration: none; color: var(--orange-600); }
.site-nav a:hover { text-decoration: underline; }
.username { color: var(--ink-600); }

/* layout */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* login hero */

.hero {
  text-align: center;
  padding: 3rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.hero-mark {
  position: relative;
  width: 4rem;
  height: 4rem;
  margin-bottom: 0.5rem;
}

.hero-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.hero-mark-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--orange-500);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  border-radius: 1rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.01em;
}

.hero-sub {
  color: var(--ink-600);
  font-size: 1.05rem;
  max-width: 30ch;
  margin: 0;
}

/* buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.button-primary {
  background: var(--orange-500);
  color: #fff;
}

.button-primary:hover { background: var(--orange-600); }
.button-primary:active { transform: translateY(1px); }

.button-secondary {
  background: transparent;
  color: var(--orange-600);
  border: 1px solid var(--orange-500);
}

.button-secondary:hover { background: var(--orange-100); }

/* create card */

.create-card h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 1rem;
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.create-form-row {
  display: flex;
  gap: 0.75rem;
}

.create-form-row input { flex: 1; min-width: 0; }

input[type="url"], input[type="text"] {
  font: inherit;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-50);
  color: var(--ink-900);
  width: 100%;
}

input[type="url"] { font-size: 1.05rem; }

input:focus-visible {
  outline: 2px solid var(--orange-500);
  outline-offset: 1px;
}

.flash-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: -0.5rem 0 0.75rem;
}

/* links list */

.links-section h2, .api-section h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 1rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--paper-50);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.empty-state {
  color: var(--ink-600);
  font-size: 0.95rem;
}

.ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ticket {
  display: flex;
  align-items: stretch;
  background: var(--paper-50);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.ticket-stub {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  min-width: 0;
}

.ticket-stub-target { flex: 1 1 auto; min-width: 0; }
.ticket-stub-code { flex: none; align-items: flex-end; text-align: right; }

.ticket-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-600);
}

.ticket-target {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-clicks {
  font-size: 0.8rem;
  color: var(--ink-600);
}

.ticket-code {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--orange-600);
  text-decoration: none;
}

.ticket-code:hover { text-decoration: underline; }

.ticket-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.link-action {
  font: inherit;
  font-size: 0.78rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--ink-600);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-action:hover { color: var(--ink-900); }
.link-action.danger { color: var(--danger); }
.link-action.danger:hover { color: var(--danger); opacity: 0.8; }

.ticket-perforation {
  position: relative;
  width: 0;
  flex: none;
  border-left: 2px dashed var(--line);
}

.ticket-perforation::before,
.ticket-perforation::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper-0);
}

.ticket-perforation::before { top: -8px; }
.ticket-perforation::after { bottom: -8px; }

@media (max-width: 560px) {
  .ticket { flex-direction: column; }
  .ticket-stub-code { align-items: flex-start; text-align: left; }
  .ticket-perforation {
    width: auto;
    height: 0;
    border-left: none;
    border-top: 2px dashed var(--line);
  }
  .ticket-perforation::before,
  .ticket-perforation::after {
    top: 50%;
    transform: translateY(-50%);
  }
  .ticket-perforation::before { left: -8px; }
  .ticket-perforation::after { left: auto; right: -8px; }
}

/* api keys */

.section-sub {
  color: var(--ink-600);
  font-size: 0.9rem;
  margin: -0.5rem 0 1rem;
}

.key-reveal {
  background: var(--orange-100);
  border: 1px solid var(--orange-500);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.key-reveal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.key-reveal-token {
  font-size: 0.85rem;
  word-break: break-all;
  background: none;
  padding: 0;
}

.key-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.key-form input { flex: 1; min-width: 0; }

.key-list {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-50);
  font-size: 0.85rem;
}

.key-name { font-weight: 600; margin-right: 0.5rem; }
.key-prefix { color: var(--ink-600); }

.key-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink-600);
  font-size: 0.8rem;
}

.api-example {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--paper-50);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0;
}

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