:root {
  --ink: #17211b;
  --muted: #67726b;
  --paper: #f5f1e8;
  --surface: #fffdf8;
  --line: #ded9cf;
  --green: #1f6f4a;
  --green-dark: #155238;
  --green-soft: #dceade;
  --orange: #d56b31;
  --danger: #a63b32;
  --shadow: 0 18px 45px rgba(38, 46, 41, 0.08);
  --shadow-soft: 0 8px 26px rgba(38, 46, 41, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; }
button { cursor: pointer; }
a, button, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(31,111,74,.24); outline-offset: 2px; }
.hidden { display: none !important; }

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0;
  display: flex;
  gap: 24px;
  align-items: center;
  position: relative;
  z-index: 5;
}

.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  color: white; background: var(--green); border-radius: 13px;
  font-size: 23px; font-weight: 700; box-shadow: 0 7px 18px rgba(31,111,74,.25);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex: 0 0 auto; }
.admin-badge { color: var(--green); background: var(--green-soft); padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.site-search {
  width: min(520px, 100%); height: 44px; display: flex; align-items: center; gap: 11px;
  margin: 0 auto; padding: 0 13px; background: rgba(255,253,248,.8);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-soft);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.site-search:focus-within { background: var(--surface); border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,111,74,.12), var(--shadow-soft); }
.site-search svg { width: 19px; flex: 0 0 auto; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.site-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }

.button {
  min-height: 40px; border: 0; border-radius: 11px; padding: 10px 16px; font-weight: 700;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-quiet { color: var(--ink); background: rgba(255,255,255,.55); border: 1px solid var(--line); }
.button-danger { color: var(--danger); background: transparent; border: 1px solid #ebcbc6; padding: 8px 11px; }
.button-full { width: 100%; padding: 13px 18px; }

.eyebrow { margin: 0 0 13px; color: var(--orange); font-size: 11px; font-weight: 800; letter-spacing: .17em; }
kbd { color: var(--muted); background: #ede9e0; border: 1px solid #d8d2c7; border-radius: 6px; padding: 3px 8px; font-size: 12px; }

.library {
  background: rgba(255,253,248,.72); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 38px max(20px, calc((100vw - 1180px) / 2)) 44px;
  flex: 1;
}
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 32px; margin-bottom: 24px; }
.section-title { min-width: 0; }
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 34px; font-weight: 500; letter-spacing: -.035em; }
.section-copy { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.section-side { display: flex; align-items: flex-end; gap: 22px; }
.service-summary { min-width: 220px; padding-right: 22px; border-right: 1px solid var(--line); }
.service-summary > span { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.service-summary > span i { width: 7px; height: 7px; border-radius: 50%; background: #3ba26d; box-shadow: 0 0 0 4px rgba(59,162,109,.1); }
.service-summary small { display: block; color: var(--muted); font-size: 10px; margin-top: 6px; }
.section-actions { display: flex; align-items: center; gap: 14px; }
.file-count { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; background: rgba(245,241,232,.8); border: 1px solid var(--line); padding: 8px 11px; border-radius: 999px; }
.file-count i { width: 6px; height: 6px; background: #3ba26d; border-radius: 50%; }
.file-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.file-card {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 15px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); padding: 16px; border-radius: 15px;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.file-card:hover { border-color: #bbb6ac; transform: translateY(-2px); box-shadow: 0 12px 28px rgba(38,46,41,.07); }
.file-icon {
  width: 46px; height: 50px; display: grid; place-items: center; position: relative;
  color: var(--green); background: var(--green-soft); border-radius: 9px 9px 12px 9px; font-size: 12px; font-weight: 800;
}
.file-icon::after { content: ""; position: absolute; right: 0; top: 0; border-style: solid; border-width: 0 0 11px 11px; border-color: transparent transparent rgba(31,111,74,.25) transparent; }
.file-info { min-width: 0; }
.file-name { margin: 0 0 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 720; letter-spacing: -.01em; }
.file-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 11px; }
.file-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; background: #3ba26d; border-radius: 50%; vertical-align: 1px; }
.file-actions { display: flex; gap: 7px; }
.download-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.state-card { min-height: 150px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; background: rgba(245,241,232,.42); border: 1px dashed #d6d0c5; border-radius: 16px; }
.state-card h3 { color: var(--ink); margin: 12px 0 5px; }
.state-card p { margin: 0; }
.empty-icon { font-size: 48px; color: var(--green); }
.spinner { width: 27px; height: 27px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { margin-bottom: 18px; padding: 12px 15px; border-radius: 10px; background: var(--green-soft); color: var(--green-dark); font-size: 13px; }
.notice.error { background: #f5ded9; color: var(--danger); }

footer {
  width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 14px 0;
  color: var(--muted); display: flex; justify-content: space-between; font-size: 11px;
}
#footerStatus i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #3ba26d; }

dialog { border: 0; border-radius: 18px; padding: 0; color: var(--ink); background: transparent; box-shadow: var(--shadow); }
dialog[open] { animation: dialog-in .18s ease-out; }
dialog::backdrop { background: rgba(23,33,27,.52); backdrop-filter: blur(5px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-card { width: min(430px, calc(100vw - 28px)); background: var(--surface); padding: 32px; position: relative; }
.dialog-wide { width: min(650px, calc(100vw - 28px)); }
.dialog-card h2 { font: 500 34px/1.1 Georgia, serif; letter-spacing: -.03em; margin: 0 0 9px; }
.dialog-card > p:not(.eyebrow):not(.form-error) { color: var(--muted); line-height: 1.6; margin: 0 0 24px; font-size: 13px; }
.dialog-close { position: absolute; right: 16px; top: 14px; border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.dialog-card label:not(.drop-zone) { display: grid; gap: 8px; margin-bottom: 15px; font-size: 12px; font-weight: 700; }
.dialog-card input[type="password"] { border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: 0; background: white; }
.dialog-card input[type="password"]:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,111,74,.1); }
.form-error { color: var(--danger); font-size: 12px; margin: -5px 0 12px; }
.drop-zone {
  display: grid; justify-items: center; gap: 7px; padding: 28px 20px; border: 1.5px dashed #aaa79f;
  border-radius: 14px; background: #f8f5ee; text-align: center; cursor: pointer;
}
.drop-zone.dragging { border-color: var(--green); background: var(--green-soft); }
.drop-zone input { display: none; }
.drop-zone small { color: var(--muted); font-weight: 400; }
.drop-icon { width: 38px; height: 38px; display: grid; place-items: center; color: white; background: var(--green); border-radius: 50%; font-size: 20px; }
.upload-queue { display: grid; gap: 9px; max-height: 250px; overflow: auto; margin-top: 15px; }
.upload-item { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.upload-item-row { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 8px; font-size: 12px; }
.upload-item-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-row span { color: var(--muted); white-space: nowrap; }
.progress { height: 5px; background: #e9e5dc; border-radius: 999px; overflow: hidden; }
.progress span { display: block; width: 0; height: 100%; background: var(--green); transition: width .18s linear; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

@media (max-width: 760px) {
  .site-header { width: min(100% - 28px, 1180px); flex-wrap: wrap; gap: 12px; }
  .brand small, .admin-badge { display: none; }
  .header-actions { margin-left: auto; }
  .site-search { order: 3; width: 100%; height: 46px; }
  .library { padding: 30px 14px 32px; }
  .file-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: stretch; flex-direction: column; gap: 18px; }
  .section-side { align-items: center; justify-content: space-between; gap: 12px; }
  .service-summary { min-width: 0; padding-right: 0; border-right: 0; }
  .service-summary small { display: none; }
  .section-actions { margin-left: auto; }
  .file-card { grid-template-columns: auto minmax(0, 1fr); }
  .file-actions { grid-column: 1 / -1; }
  .download-link, .button-danger { flex: 1; }
  footer { width: calc(100% - 28px); gap: 10px; }
}

@media (min-width: 761px) and (max-width: 980px) {
  .service-summary { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
