/* Zukor Cloud. Blue, white and black, with red reserved as a danger signal.
   Blue carries the brand and every interactive affordance. Red appears only
   on destructive actions and errors, so red always means "stop and look". */

:root {
  --blue: #12449E;
  --blue-dark: #0D3578;
  --red: #E2231A;
  --red-dark: #B81B14;
  --ink: #000000;
  --line: #D4DAE3;
  --line-soft: #E6EAF0;
  --paper: #FFFFFF;
  --ground: #F5F7FA;
  --hover: #EDF2F9;
  --select: #E3ECF9;
  --topbar-h: 56px;
  --sidebar-w: 236px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: Helvetica, Arial, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- Sign in ---------- */
.signin { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.signin-card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 34px; width: 100%; max-width: 380px; }
.brand-logo { display: block; width: 232px; max-width: 100%; height: auto; }
.signin-sub { margin: 10px 0 26px; font-size: 14px; color: var(--ink); }
.signin-card label { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 5px; }
.signin-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.signin-card input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.btn-block { width: 100%; margin-top: 22px; }
.form-error { color: var(--red); font-size: 14px; margin-top: 12px; min-height: 20px; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--blue); color: #fff; border: 0; border-radius: 6px;
  padding: 9px 16px; font-weight: 700; cursor: pointer;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-plain {
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 14px; cursor: pointer;
}
.btn-plain:hover { background: var(--hover); }
.btn-danger { color: var(--red); font-weight: 700; }
.icon-btn {
  background: none; border: 0; padding: 7px; border-radius: 6px; cursor: pointer;
  color: var(--ink); display: inline-flex; align-items: center;
}
.icon-btn:hover { background: var(--hover); }

/* ---------- Layout ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) calc(14px + env(safe-area-inset-right)) 0 calc(14px + env(safe-area-inset-left));
}
.brand { flex: 0 0 auto; display: inline-flex; align-items: center; }
.brand-word { display: block; width: 124px; height: auto; }
.brand-cloud { display: none; width: 30px; height: 30px; }
.menu-btn { display: none; }

.searchwrap { flex: 1 1 auto; position: relative; max-width: 620px; }
.searchwrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink); }
#search {
  width: 100%; padding: 9px 40px 9px 34px; border: 1px solid var(--line);
  border-radius: 20px; background: var(--ground);
}
#search:focus { outline: 2px solid var(--blue); outline-offset: -1px; background: var(--paper); }
.kbd-hint {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; background: var(--paper);
}

.body { flex: 1 1 auto; display: flex; min-height: 0; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto; background: var(--paper);
  border-right: 1px solid var(--line); overflow-y: auto; padding: 14px 0 28px;
}
.side-section { padding: 0 10px 18px; }
.side-title { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; padding: 0 8px 7px; }
.side-link, .ws-link {
  display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 6px;
  color: var(--ink); font-size: 14px; cursor: pointer;
}
.side-link:hover, .ws-link:hover { background: var(--hover); }
.side-link.active, .ws-link.active { background: var(--select); font-weight: 700; }
.ws-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.ws-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-count { font-size: 12px; }
.side-foot { padding: 14px 18px 0; font-size: 12px; border-top: 1px solid var(--line-soft); margin: 0 10px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 8px; }

.content { flex: 1 1 auto; overflow-y: auto; padding: 18px 22px 80px; min-width: 0; }
.detail {
  width: 340px; flex: 0 0 auto; background: var(--paper); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 18px 18px 60px;
}

/* ---------- Breadcrumbs and headings ---------- */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; font-size: 14px; }
.crumbs a { cursor: pointer; }
.crumbs .sep { color: var(--ink); }
h1.page-title { font-size: 21px; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
.page-sub { font-size: 14px; margin: 0 0 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 10px; }
.section-head h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin: 0; }

/* ---------- Folder grid ---------- */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 10px; }
.folder-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 13px 14px;
  cursor: pointer; display: flex; align-items: center; gap: 11px;
}
.folder-card:hover { border-color: var(--blue); }
.folder-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-meta { font-size: 12px; }

/* ---------- File list ---------- */
.file-list { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.file-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--hover); }
.file-row.selected { background: var(--select); }
.file-main { flex: 1 1 auto; min-width: 0; }
.file-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-excerpt { font-size: 13px; margin-top: 3px; }
.file-excerpt mark { background: #CFE0F7; color: var(--ink); padding: 0 1px; font-weight: 700; }
.file-size { font-size: 12.5px; flex: 0 0 auto; white-space: nowrap; }
.file-actions { display: flex; gap: 2px; flex: 0 0 auto; }

.thumb {
  width: 34px; height: 34px; border-radius: 6px; flex: 0 0 auto;
  object-fit: cover; background: var(--ground); border: 1px solid var(--line-soft);
}
.kind {
  width: 34px; height: 34px; border-radius: 6px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em; color: #fff; text-transform: uppercase;
}
.kind.doc { background: #12449E; }
.kind.sheet { background: #0D3578; }
.kind.deck { background: #4A86D8; }
.kind.image { background: #1B6FD1; }
.kind.audio { background: #2B3442; }
.kind.video { background: #000000; }
.kind.drawing { background: #3A3A3A; }
.kind.archive { background: #5E5E5E; }
.kind.file { background: #767676; }

.empty { border: 1px dashed var(--line); border-radius: 8px; padding: 34px 20px; text-align: center; background: var(--paper); }
.empty strong { display: block; margin-bottom: 5px; font-size: 15px; }

.pill {
  display: inline-block; border: 1px solid var(--line); border-radius: 12px;
  padding: 1px 9px; font-size: 12px; background: var(--paper); cursor: pointer;
}
.pill:hover { border-color: var(--blue); }
.pill.active { background: var(--select); border-color: var(--blue); font-weight: 700; }

/* ---------- Detail panel ---------- */
.detail h3 { font-size: 16px; margin: 0 0 3px; word-break: break-word; }
.detail .meta-line { font-size: 13px; margin-bottom: 16px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
}
.field textarea { min-height: 68px; resize: vertical; }
.preview-text {
  background: var(--ground); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 11px; font-size: 13px; max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.preview-img { width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.version-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }

/* ---------- Upload, toast, modal ---------- */
.dropzone {
  position: fixed; inset: 0; background: rgba(18, 68, 158, 0.10);
  border: 3px dashed var(--blue); z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.dropzone div { background: var(--paper); border-radius: 10px; padding: 20px 34px; font-size: 19px; font-weight: 700; }

.uploads {
  position: fixed; right: 18px; bottom: 18px; width: 320px; z-index: 50;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.upload-item { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.upload-item:last-child { border-bottom: 0; }
.bar { height: 3px; background: var(--line-soft); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--blue); width: 0; transition: width .18s; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 90; font-size: 14px;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.34); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--paper); border-radius: 10px; padding: 24px; width: 100%; max-width: 440px;
  max-height: 86vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.copyrow { display: flex; gap: 7px; }
.copyrow input { flex: 1 1 auto; }

table.data { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; }
table.data tr:last-child td { border-bottom: 0; }
code.token { background: var(--ground); padding: 2px 6px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .detail {
    position: fixed; inset: calc(var(--topbar-h) + env(safe-area-inset-top)) 0 0 auto;
    width: min(380px, 92vw); z-index: 40; box-shadow: -4px 0 20px rgba(0,0,0,.12);
  }
}
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; inset: calc(var(--topbar-h) + env(safe-area-inset-top)) auto 0 0;
    z-index: 45; transform: translateX(-100%); transition: transform .18s; box-shadow: 3px 0 18px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: none; }
  .brand-word { width: 104px; }
  .content { padding: 14px 14px 90px; }
  .upload-btn { padding: 9px 12px; }
  .kbd-hint { display: none; }
  .uploads { left: 12px; right: 12px; width: auto; }
}

/* On a narrow phone the search field needs the whole bar, so the wordmark
   gives way to the cloud on its own. The brand stays, the row still fits. */
@media (max-width: 560px) {
  .brand-word { display: none; }
  .brand-cloud { display: block; }
}

/* ---------- iOS and other touch devices ----------
   Safari zooms the page whenever a focused field is under 16px, which on a
   phone leaves the layout shifted and the user pinching back out. Every
   control that takes typing is therefore 16px on a touch device. */
@media (hover: none) and (pointer: coarse) {
  input, select, textarea, button { font-size: 16px; }
  table.data th, table.data td { font-size: 15px; }
  .side-link, .ws-link { padding: 11px 9px; }
  .btn-plain, .btn-primary { padding: 11px 16px; }
}

/* Safari's grey flash on tap reads as a rendering fault rather than feedback. */
* { -webkit-tap-highlight-color: transparent; }

/* Keep momentum scrolling inside the panes, and stop the whole page from
   rubber-banding behind them. */
.sidebar, .content, .detail, .modal {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Home-indicator clearance: anything anchored to the bottom of the window
   sits above it rather than under it. */
.content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.sidebar { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.uploads { bottom: calc(18px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(22px + env(safe-area-inset-bottom)); }
.modal-backdrop { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }

.count-note { font-size: 12.5px; color: var(--ink); opacity: 0.75; }
