:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #69736e;
  --line: #dfe5e1;
  --paper: #ffffff;
  --canvas: #f4f6f4;
  --green: #1b6b4b;
  --green-dark: #115139;
  --gold: #e8b85d;
  --danger: #b53737;
  font-family: "Segoe UI Variable", "Aptos", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .72; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(232, 184, 93, .22), transparent 30%),
    radial-gradient(circle at 90% 85%, rgba(27, 107, 75, .2), transparent 34%),
    #edf1ed;
}

.login-card {
  width: min(100%, 410px);
  padding: 38px;
  border: 1px solid rgba(27, 107, 75, .12);
  border-radius: 28px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 28px 80px rgba(22, 42, 32, .14);
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: var(--green);
  color: white;
  font-weight: 800;
  letter-spacing: -.06em;
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 14px; }
.eyebrow { margin: 24px 0 6px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .15em; }
h1 { margin: 0; font-size: 34px; letter-spacing: -.04em; }
.login-hint { margin: 10px 0 28px; color: var(--muted); }
label > span { display: block; margin: 0 0 7px; font-size: 13px; font-weight: 700; }
input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #cbd4ce;
  border-radius: 12px;
  background: white;
  outline: none;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(27, 107, 75, .12); }
.login-card label + label { display: block; margin-top: 16px; }
.form-error { min-height: 20px; margin: 10px 0; color: var(--danger); font-size: 13px; }

.primary, .secondary, .text-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border-radius: 12px;
  border: 0;
  font-weight: 700;
  text-decoration: none;
}
.primary { background: var(--green); color: white; }
.primary:hover { background: var(--green-dark); }
.secondary { border: 1px solid var(--line); background: white; color: var(--ink); }
.secondary:hover { border-color: #b8c4bd; background: #f9faf9; }
.text-button { background: transparent; color: var(--muted); }
.wide { width: 100%; }

.app { min-height: 100dvh; }
.topbar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); }
.icon-button:hover { background: #e9edea; }
.icon-button svg, button svg, .search svg { width: 20px; height: 20px; }

main { width: min(1440px, 100%); margin: 0 auto; padding: 28px clamp(18px, 4vw, 54px) 60px; }
.path-row { min-height: 48px; display: flex; align-items: center; gap: 4px; }
.back:disabled { opacity: .25; cursor: default; }
.breadcrumbs { display: flex; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.crumb { border: 0; background: transparent; color: var(--muted); padding: 8px 7px; white-space: nowrap; font-weight: 650; }
.crumb:last-child { color: var(--ink); font-weight: 800; }
.crumb + .crumb::before { content: "/"; margin-right: 14px; color: #a8b0ab; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 16px 0 26px; }
.toolbar-actions { display: flex; gap: 10px; }
.search { width: min(360px, 40vw); position: relative; }
.search span { position: absolute; left: 14px; top: 14px; color: var(--muted); }
.search input { padding-left: 43px; border-color: transparent; background: #e9edea; }

.drop-zone { min-height: 55vh; position: relative; }
.drop-overlay { position: absolute; inset: 0; display: none; place-items: center; border: 2px dashed var(--green); border-radius: 22px; background: rgba(235, 245, 239, .95); color: var(--green); font-size: 20px; font-weight: 800; z-index: 5; pointer-events: none; }
.drop-zone.dragging .drop-overlay { display: grid; }
.content { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }

.entry {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 5px 16px rgba(27, 45, 36, .035);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  position: relative;
  touch-action: pan-y;
  user-select: none;
}
.entry:hover { transform: translateY(-2px); border-color: #c5d0c9; box-shadow: 0 12px 24px rgba(27, 45, 36, .08); }
.entry.selected { border-color: var(--green); box-shadow: 0 0 0 3px rgba(27, 107, 75, .18); transform: translateY(-2px); }
.selection-check { position: absolute; top: 9px; right: 9px; width: 29px; height: 29px; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.9); border-radius: 50%; background: rgba(21, 34, 27, .5); color: white; z-index: 3; opacity: 0; transform: scale(.7); transition: .15s ease; pointer-events: none; }
.selection-check svg { width: 17px; height: 17px; }
.entry.selected .selection-check { opacity: 1; transform: scale(1); background: var(--green); }
.entry-preview { width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; border: 0; background: #e8ece9; padding: 0; position: relative; }
.entry-preview img, .entry-preview video { width: 100%; height: 100%; object-fit: cover; }
.entry-preview video { pointer-events: none; }
.folder-preview { background: linear-gradient(145deg, #fff3d6, #f4d286); color: #8f6517; }
.folder-preview svg { width: 70px; height: 70px; }
.play-badge { position: absolute; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: rgba(10, 18, 14, .68); color: white; }
.entry-info { display: flex; align-items: center; gap: 9px; padding: 13px 12px; }
.entry-copy { min-width: 0; flex: 1; }
.entry-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.entry-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.delete { flex: 0 0 auto; width: 34px; height: 34px; color: #8b9490; }
.delete:hover { color: var(--danger); background: #f9eaea; }

.empty { grid-column: 1 / -1; min-height: 48vh; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty svg { width: 72px; height: 72px; color: #b7c0bb; }
.empty h2 { margin: 16px 0 6px; color: var(--ink); }
.skeleton { height: 240px; border-radius: 18px; background: linear-gradient(90deg, #e9edea 25%, #f6f8f6 40%, #e9edea 65%); background-size: 300% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -100% 0; } }

dialog { padding: 0; border: 0; border-radius: 22px; box-shadow: 0 26px 80px rgba(15, 26, 20, .25); }
dialog::backdrop { background: rgba(10, 18, 14, .58); backdrop-filter: blur(3px); }
.dialog-card { width: min(440px, calc(100vw - 32px)); padding: 26px; }
.dialog-card h2 { margin: 0 0 24px; }
.notes-card { width: min(680px, calc(100vw - 32px)); }
.notes-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.notes-heading-actions { display: flex; align-items: center; gap: 7px; }
.notes-heading .eyebrow { margin: 0 0 5px; }
.notes-heading h2 { margin: 0; }
.notes-editor { display: flex; flex-direction: column; min-height: 0; }
.notes-card textarea { width: 100%; min-height: min(52vh, 460px); margin-top: 22px; padding: 16px; resize: vertical; border: 1px solid #cbd4ce; border-radius: 14px; background: #fbfcfb; color: var(--ink); font: 16px/1.55 "Segoe UI Variable", "Aptos", "Trebuchet MS", sans-serif; outline: none; }
.notes-card textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(27, 107, 75, .12); }
.notes-status { min-height: 22px; padding-top: 8px; color: var(--muted); font-size: 12px; text-align: right; }
.notes-status.saving { color: #9a6b12; }
.notes-status.error { color: var(--danger); }
.notes-history { min-height: min(56vh, 500px); margin-top: 18px; }
.history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.notes-history-list { max-height: min(50vh, 440px); overflow-y: auto; padding: 8px 2px; }
.history-empty { padding: 70px 20px; color: var(--muted); text-align: center; }
.history-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 13px 10px; border-bottom: 1px solid #edf0ee; }
.history-item-copy { min-width: 0; }
.history-item time { display: block; color: var(--ink); font-size: 13px; font-weight: 750; }
.history-preview { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.history-item .secondary { min-height: 38px; padding-inline: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.preview-dialog { width: min(1100px, calc(100vw - 30px)); max-width: none; background: #101512; color: white; }
.preview-shell { height: min(820px, calc(100dvh - 30px)); display: grid; grid-template-rows: auto 1fr; }
.preview-shell header { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.preview-shell header > div:first-child { min-width: 0; }
.preview-shell strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-shell header span { display: block; margin-top: 4px; color: #a9b2ad; font-size: 12px; }
.preview-actions { display: flex; align-items: center; gap: 8px; }
.preview-actions .secondary { background: #f4f6f4; }
.preview-actions .close { color: white; }
.preview-content { min-height: 0; display: grid; place-items: center; overflow: auto; padding: 18px; }
.preview-content img, .preview-content video { max-width: 100%; max-height: 100%; border-radius: 8px; }

.upload-status { position: fixed; right: 24px; bottom: 24px; width: min(360px, calc(100vw - 32px)); padding: 16px; border-radius: 16px; background: #17211d; color: white; box-shadow: 0 18px 50px rgba(0,0,0,.25); z-index: 50; }
.upload-status div { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.upload-status span { color: #c7cfca; }
progress { width: 100%; height: 7px; accent-color: var(--gold); }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 12px 18px; border-radius: 12px; background: #17211d; color: white; box-shadow: 0 10px 34px rgba(0,0,0,.2); z-index: 60; }
.selection-bar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); min-height: 64px; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 9px 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; background: #17211d; color: white; box-shadow: 0 20px 50px rgba(0,0,0,.3); z-index: 45; }
.selection-cancel { color: white; }
.selection-bar .primary { background: var(--gold); color: #30230b; }

@media (max-width: 680px) {
  .topbar { height: 62px; }
  main { padding-top: 15px; padding-bottom: calc(36px + env(safe-area-inset-bottom)); }
  .toolbar { align-items: stretch; flex-direction: column; margin-top: 10px; }
  .toolbar-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .toolbar-actions button { padding-inline: 10px; }
  .toolbar-actions button span { font-size: 13px; }
  .search { width: 100%; }
  .content { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .entry { border-radius: 14px; }
  .entry-info { padding: 10px; }
  .entry-meta { display: none; }
  .delete { width: 30px; height: 30px; }
  .login-card { padding: 28px 22px; border-radius: 22px; }
  .preview-dialog { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
  .preview-shell { height: 100dvh; }
  .preview-shell header { padding-top: calc(10px + env(safe-area-inset-top)); }
  .preview-actions .secondary span { display: none; }
  .upload-status { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .selection-bar { bottom: calc(12px + env(safe-area-inset-bottom)); min-height: 60px; grid-template-columns: 40px 1fr auto; border-radius: 16px; }
  .selection-bar .primary span { display: none; }
  .notes-card { height: min(82dvh, 680px); display: flex; flex-direction: column; }
  .notes-editor { flex: 1; }
  .notes-card textarea { flex: 1; min-height: 0; resize: none; }
  .notes-history { flex: 1; min-height: 0; }
  .notes-history-list { max-height: calc(82dvh - 170px); }
  .notes-heading-actions .secondary { min-height: 40px; padding-inline: 12px; }
}
