:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #657168;
  --paper: #f6f3eb;
  --panel: #fffcf5;
  --line: #ded9cd;
  --green: #286044;
  --green-dark: #183d2a;
  --lime: #dcec96;
  --red: #a23a35;
  --shadow: 0 18px 48px rgba(34, 43, 36, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}

a { color: inherit; }
button, input, textarea { font: inherit; }
button, input, textarea { color: var(--ink); }

.topbar {
  height: 68px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--green-dark);
  color: #fff;
}

.brand {
  color: inherit;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 700;
  letter-spacing: -.045em;
  text-decoration: none;
}

.brand span { color: var(--lime); }
.account { display: flex; gap: 16px; align-items: center; }
.account form { margin: 0; }
.user-chip { color: #d9e4dc; font-size: 14px; }
.text-button { border: 0; padding: 0; background: transparent; color: #fff; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.unencrypted-banner {
  min-height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  background: #fff0c9;
  border-bottom: 1px solid #e7d599;
  color: #594915;
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: clamp(30px, 4vw, 64px);
  width: min(1460px, calc(100% - 48px));
  margin: 42px auto 80px;
}

.sidebar { min-width: 0; }
.upload-panel, .auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.upload-panel { padding: 26px; }
.upload-panel h1 { margin: 3px 0 22px; font-family: Georgia, serif; font-size: 30px; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }

.stack-form { display: grid; gap: 16px; }
.stack-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.stack-form label span { display: flex; justify-content: space-between; }
.stack-form label i { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 500; }
.stack-form small { color: var(--muted); font-size: 11px; font-weight: 400; }
.centered { text-align: center; }

.clipboard-paste {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1.5px dashed #8ba08f;
  border-radius: 12px;
  padding: 14px;
  background: #f2f7e9;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.clipboard-paste:hover { border-color: var(--green); background: #ecf4df; }
.clipboard-paste:focus-visible { outline: 3px solid rgba(40, 96, 68, .18); outline-offset: 2px; }
.clipboard-paste:disabled { cursor: wait; opacity: .65; }
.paste-icon {
  flex: none;
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: -.03em;
}
.paste-copy { min-width: 0; display: grid; gap: 3px; }
.paste-copy strong { color: var(--green-dark); font-size: 14px; }
.paste-copy small { line-height: 1.35; }
.paste-status { margin: -10px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.paste-status.is-error { color: var(--red); }
.form-divider { display: flex; align-items: center; gap: 8px; color: #8a928b; font-size: 9px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.form-divider::before, .form-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.form-divider span { flex: none; }

input, textarea {
  width: 100%;
  border: 1px solid #cfc9bc;
  border-radius: 9px;
  padding: 11px 12px;
  background: #fff;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(40, 96, 68, .12); }
textarea { resize: vertical; line-height: 1.55; }

.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: #e9e6dc; }
.mode-tabs label { display: block; padding: 8px; border-radius: 8px; text-align: center; font-size: 12px; cursor: pointer; }
.mode-tabs label:has(input:checked) { background: #fff; box-shadow: 0 2px 7px rgba(0,0,0,.08); }
.mode-tabs input { width: auto; position: absolute; opacity: 0; }

.file-drop {
  min-height: 125px;
  place-content: center;
  text-align: center;
  border: 1.5px dashed #a8b2a9;
  border-radius: 12px;
  background: #f7f9f3;
  cursor: pointer;
}
.file-drop input { width: 1px; height: 1px; position: absolute; opacity: 0; }
.file-drop strong { color: var(--green); font-size: 14px; }
.file-drop > span { display: block !important; color: var(--muted); font-size: 11px; font-weight: 400; }
.is-hidden { display: none !important; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid #c8c2b5;
  border-radius: 9px;
  padding: 10px 15px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { border-color: var(--green); }
.button:disabled { cursor: wait; opacity: .65; }
.button-primary { border-color: var(--green); background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-small { padding: 7px 10px; font-size: 11px; }
.button-danger { border-color: #e1beb9; color: var(--red); }

.tag-nav { margin-top: 30px; }
.tag-nav .eyebrow { padding: 0 10px 7px; }
.tag-filter { display: flex; align-items: center; justify-content: space-between; padding: 9px 11px; border-radius: 9px; color: var(--muted); font-size: 13px; text-decoration: none; }
.tag-filter:hover, .tag-filter.is-active { color: var(--green-dark); background: rgba(255,255,255,.68); }
.tag-filter b { min-width: 24px; border-radius: 20px; padding: 2px 7px; background: #e3dfd4; text-align: center; font-size: 10px; }

.library { min-width: 0; }
.library-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.library-head h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(32px, 4vw, 48px); letter-spacing: -.035em; }
.search-form { display: flex; gap: 8px; width: min(100%, 420px); }
.search-form input { min-width: 0; }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); gap: 22px; }
.item-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 8px 26px rgba(34,43,36,.055); }
.preview { height: 205px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; background: #e5e6dd; color: var(--green-dark); }
.preview img, .preview video { width: 100%; height: 100%; }
.preview img { object-fit: contain; }
.preview video { object-fit: cover; }
.preview-video { background: #17211b; }
.preview-audio { padding: 25px; background: linear-gradient(145deg, #dce5d8, #f0e3c9); }
.preview-audio audio { width: 100%; margin-top: 23px; }
.preview-text { align-items: stretch; justify-content: start; padding: 19px; background: #f0ede4; }
.preview-text pre { margin: 0; overflow: hidden; color: #475149; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.preview-book { background: linear-gradient(145deg, #e4d2ad, #f5eee0); }
.preview-file { background: linear-gradient(145deg, #d9e2de, #f0f1ed); }
.preview > span { margin-top: 7px; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.media-icon { font-family: Georgia, serif; font-size: 64px; line-height: 1; }

.item-body { padding: 18px; }
.item-title-row { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.item-title-row > div { min-width: 0; }
.item-title-row h3 { margin: 0; overflow: hidden; font-family: Georgia, serif; font-size: 19px; text-overflow: ellipsis; white-space: nowrap; }
.item-title-row p { margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.kind-badge { flex: none; border-radius: 20px; padding: 4px 8px; background: #e7eadf; color: var(--green); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 13px; }
.tag-row a { border-radius: 5px; padding: 3px 6px; background: #edf0e6; color: var(--green); font-size: 10px; font-weight: 700; text-decoration: none; }
.item-meta { margin: 14px 0 0; color: #879087; font-size: 10px; }
.item-details { margin-top: 13px; border-top: 1px solid #e7e2d7; padding-top: 11px; }
.item-details summary { color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.tag-edit { display: flex; gap: 7px; margin-top: 11px; }
.tag-edit input { min-width: 0; padding: 7px 9px; font-size: 11px; }
.item-actions { display: flex; justify-content: space-between; margin-top: 8px; }
.item-actions form { margin: 0; }

.alert { margin: 0 0 20px; border: 1px solid; border-radius: 10px; padding: 11px 13px; font-size: 13px; }
.alert-error { border-color: #e1b9b4; background: #fff0ee; color: #7f2d29; }
.alert-success { border-color: #bad3bd; background: #eef8ed; color: #285d31; }
.empty-state { margin-top: 80px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 12px 0 5px; color: var(--ink); font-family: Georgia, serif; font-size: 24px; }
.empty-state p { margin: 0; }
.empty-mark { color: #aeb8ad; font-size: 58px; }

.auth-body { display: grid; place-items: center; padding: 36px 20px; background: radial-gradient(circle at 20% 10%, #e4edc6, transparent 30%), var(--green-dark); }
.auth-shell { width: min(100%, 430px); }
.auth-brand { display: block; margin: 0 auto 20px; color: #fff; text-align: center; }
.auth-card { padding: 35px; }
.auth-card h1 { margin: 4px 0 4px; font-family: Georgia, serif; font-size: 38px; letter-spacing: -.035em; }
.auth-card > .muted { margin: 0 0 23px; }
.auth-switch { margin: 22px 0 0; color: var(--muted); text-align: center; font-size: 13px; }
.auth-switch a { color: var(--green); font-weight: 700; }
.prototype-note { margin: 18px auto 0; color: #b8c7bc; text-align: center; font-size: 11px; line-height: 1.5; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; width: min(100% - 30px, 620px); margin-top: 25px; }
  .sidebar { display: contents; }
  .tag-nav { order: 2; margin-top: 0; }
  .library { order: 1; }
  .upload-panel { order: 0; }
  .library-head { align-items: stretch; flex-direction: column; }
  .search-form { width: 100%; }
}

@media (max-width: 520px) {
  .unencrypted-banner { align-items: flex-start; flex-direction: column; gap: 2px; }
  .item-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 27px 23px; }
  .library-head h2 { font-size: 36px; }
}
