:root {
  --ink: #12160f;
  --panel: rgba(28, 36, 24, 0.78);
  --line: rgba(232, 214, 170, 0.14);
  --text: #f3efe4;
  --muted: #a7b09a;
  --amber: #d4a24a;
  --amber-deep: #b8822e;
  --sage: #8faf7a;
  --danger: #d86a5b;
  --radius: 14px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --control-h: 2.75rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--ink);
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 90% 60% at 12% -10%, rgba(212, 162, 74, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 10%, rgba(143, 175, 122, 0.16), transparent 50%),
    linear-gradient(165deg, #0d110c 0%, #171d14 42%, #0f140e 100%);
}

.top {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.25rem clamp(1.25rem, 4vw, 3rem) 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--sage);
  font-weight: 600;
}

.hub-link {
  color: inherit;
  text-decoration: none;
}

.hub-link:hover,
.hub-link:focus-visible {
  color: var(--amber);
  outline: none;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 700;
}

.lede {
  margin: 0.75rem 0 0;
  max-width: 38rem;
  color: var(--muted);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem) 3rem;
  display: grid;
  gap: 1.25rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1.25rem 1.35rem;
}

.panel-head {
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
}

.hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.upload-form,
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.28rem;
  min-width: 7.5rem;
}

.field.grow {
  flex: 1 1 12rem;
}

.field.file-field {
  flex: 1 1 100%;
  min-width: 0;
}

.file-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.file-picker-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  min-width: 7.25rem;
  padding: 0 1.05rem;
  margin: 0;
  overflow: hidden;
  cursor: pointer;
}

.file-picker-label {
  pointer-events: none;
}

.file-input-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  font-size: 16px;
}

.file-picker-name {
  flex: 1 1 8rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker-name.is-selected {
  color: var(--text);
}

.filter-form .field:not(.field-date) {
  flex: 1 1 11rem;
  min-width: 11rem;
}

.field.field-date {
  flex: 0 0 9.5rem;
  min-width: 9.5rem;
  max-width: 11rem;
}

.field span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.2;
  min-height: 1rem;
}

input,
button {
  font: inherit;
}

input[type="text"],
input[type="search"],
input[type="date"] {
  width: 100%;
  height: var(--control-h);
  min-height: var(--control-h);
  max-height: var(--control-h);
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(12, 16, 10, 0.55);
  color: var(--text);
  padding: 0 0.75rem;
  line-height: 1.25;
  outline: none;
}

input[type="search"],
input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.75;
  cursor: pointer;
}

input:focus {
  border-color: rgba(212, 162, 74, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 162, 74, 0.15);
}

.upload-form > .btn,
.filter-form > .btn,
.template-actions .btn {
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  min-width: 7.25rem;
  padding: 0 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: linear-gradient(180deg, var(--amber), var(--amber-deep));
  border-color: transparent;
  color: #1a1408;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover,
.btn.ghost:focus-visible {
  border-color: rgba(212, 162, 74, 0.45);
  outline: none;
}

.btn.danger {
  background: transparent;
  color: #f0b0a6;
  border-color: rgba(216, 106, 91, 0.45);
}

.btn.small {
  min-height: 2.1rem;
  height: 2.1rem;
  min-width: auto;
  padding: 0 0.75rem;
  font-size: 0.88rem;
}

.library-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.filter-form {
  margin-bottom: 0.85rem;
}

.list-shell {
  max-height: min(58vh, 36rem);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  background: rgba(0, 0, 0, 0.12);
  padding: 0.55rem;
  margin-top: 0;
}

.template-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0;
}

.template-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(12, 16, 10, 0.35);
}

@media (min-width: 760px) {
  .template-card {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

.template-main h3 {
  margin: 0;
  font-size: 1.1rem;
}

.template-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.template-meta span + span::before {
  content: "·";
  margin: 0 0.4rem;
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.empty {
  margin: 1.25rem 0.5rem;
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.85rem;
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.pager-size span {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
}

.pager-size select {
  width: auto;
  min-width: 4.5rem;
  height: 2.1rem;
  min-height: 2.1rem;
  max-height: 2.1rem;
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(12, 16, 10, 0.55);
  color: var(--text);
  padding: 0 1.75rem 0 0.65rem;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.05rem) calc(50% - 0.15rem),
    calc(100% - 0.7rem) calc(50% - 0.15rem);
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
  outline: none;
}

.pager-size select:focus {
  border-color: rgba(212, 162, 74, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 162, 74, 0.15);
}

.pager-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1 1 auto;
}

.pager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pager-actions .btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.pager-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 640px) {
  .list-shell {
    max-height: min(62vh, 28rem);
  }

  .pager {
    flex-direction: column;
    align-items: stretch;
  }

  .pager-actions {
    justify-content: space-between;
  }

  .pager-actions .btn {
    flex: 1 1 auto;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(18, 22, 15, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  z-index: 20;
}

.toast.error {
  border-color: rgba(216, 106, 91, 0.55);
  color: #ffd8d3;
}

.foot {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  display: flex;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
