/* ============================================================
   CDX VAULT — industrial terminal aesthetic
   dark charcoal · amber phosphor accent · all-mono type
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #0a0c10;
  --panel: #11141a;
  --panel2: #161a22;
  --input: #0d1016;
  --line: #222835;
  --line2: #303849;
  --text: #d7dbe4;
  --dim: #8b93a5;
  --faint: #596173;
  --amber: #e8a33d;
  --amber-hi: #ffc46b;
  --amber-glow: rgba(232, 163, 61, 0.14);
  --red: #e5484d;
  --green: #68c17c;
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, "SF Mono", monospace;

  --c-note: #e8a33d;
  --c-text: #d9c06c;
  --c-image: #57c9a2;
  --c-video: #b48ef0;
  --c-audio: #6fb3f2;
  --c-pdf: #f0766b;
  --c-archive: #e0985f;
  --c-apk: #8ed05f;
  --c-bin: #8b93a5;
}

html { color-scheme: dark; }

body {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 85% -10%, var(--amber-glow), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 34px 34px, 34px 34px, auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--amber); color: #0a0c10; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes blink { 50% { opacity: 0; } }

/* ---- top bar --------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 28px;
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.08em; }
.brand:hover { color: var(--amber-hi); }
.brand-sep { color: var(--amber); }
.mainnav { display: flex; gap: 4px; }
.mainnav a {
  font-size: 11px; letter-spacing: 0.18em; color: var(--dim);
  padding: 6px 12px; border: 1px solid transparent; transition: color 0.15s;
}
.mainnav a:hover { color: var(--text); }
.mainnav a.active { color: var(--amber); border-color: var(--line); background: var(--panel); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--dim);
  border: 1px solid var(--line); background: var(--panel); padding: 5px 12px;
}
.user-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px rgba(104, 193, 124, 0.5);
  animation: pulse 2.5s infinite;
}

/* ---- layout ---------------------------------------------- */

.wrap { width: min(1060px, calc(100% - 48px)); margin: 0 auto; padding: 36px 0 64px; flex: 1; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 32px; flex-wrap: wrap;
}
.crumb { font-size: 10px; letter-spacing: 0.22em; color: var(--faint); margin-bottom: 10px; }
.crumb a { color: var(--dim); }
.crumb a:hover { color: var(--amber); }
h1 { font-size: 26px; font-weight: 700; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.page-sub {
  margin-top: 10px; font-size: 12px; color: var(--dim);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.sec { margin-bottom: 44px; }
.sec-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.sec-head h2 { font-size: 12px; letter-spacing: 0.24em; color: var(--amber); font-weight: 700; }
.sec-head h2::before { content: "▚ "; color: var(--faint); }
.sec-sub { font-size: 11px; color: var(--faint); }
.sec-head .inline-form { margin-left: auto; }

.foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 14px 28px; border-top: 1px solid var(--line);
  font-size: 10px; letter-spacing: 0.18em; color: var(--faint);
}

/* ---- stats ----------------------------------------------- */

.stats { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.stat {
  background: var(--panel); padding: 14px 22px; min-width: 110px;
  display: flex; flex-direction: column; gap: 4px;
  animation: rise 0.4s both;
}
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat-num { font-size: 20px; font-weight: 700; color: var(--amber-hi); }
.stat-label { font-size: 10px; letter-spacing: 0.2em; color: var(--dim); text-transform: uppercase; }

/* ---- buttons --------------------------------------------- */

.btn {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em;
  padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--line2); background: var(--panel2); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--amber); color: var(--amber-hi); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #131007; font-weight: 700; }
.btn.primary:hover {
  background: var(--amber-hi); border-color: var(--amber-hi); color: #131007;
  box-shadow: 0 0 18px var(--amber-glow);
}
.btn.ghost { background: transparent; }
.btn.danger { border-color: #5c2a2d; color: var(--red); background: transparent; }
.btn.danger:hover { border-color: var(--red); background: rgba(229, 72, 77, 0.08); color: #ff6b70; }
.btn.sm { padding: 6px 12px; font-size: 11px; }
.btn.block { width: 100%; justify-content: center; }

/* ---- forms ----------------------------------------------- */

input, textarea {
  font-family: var(--mono); font-size: 13px; color: var(--text);
  background: var(--input); border: 1px solid var(--line2);
  padding: 10px 12px; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-glow);
}
.field-label {
  display: block; font-size: 10px; letter-spacing: 0.2em;
  color: var(--dim); margin: 14px 0 6px;
}
.inline-form { display: flex; gap: 8px; }
.inline-form input { width: 240px; }
.stack-form .btn { margin-top: 20px; }
.hint { margin-top: 16px; font-size: 11px; color: var(--faint); }

.panel { border: 1px solid var(--line); background: var(--panel); padding: 28px; animation: rise 0.35s both; }
.panel.narrow { max-width: 460px; }
.panel .field-label:first-child { margin-top: 0; }

/* ---- flash ----------------------------------------------- */

.flash { border: 1px solid; padding: 10px 16px; font-size: 12px; margin-bottom: 20px; animation: rise 0.3s both; }
.flash.err { border-color: #5c2a2d; color: #ff8589; background: rgba(229, 72, 77, 0.07); }
.flash.ok { border-color: #2b4a33; color: #7fd493; background: rgba(104, 193, 124, 0.07); }

/* ---- badges ---------------------------------------------- */

.badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.14em;
  width: 44px; padding: 3px 0; text-align: center; flex: none;
  border: 1px solid;
}
.cat-note    { color: var(--c-note);    border-color: var(--c-note);    background: color-mix(in srgb, var(--c-note) 10%, transparent); }
.cat-text    { color: var(--c-text);    border-color: var(--c-text);    background: color-mix(in srgb, var(--c-text) 10%, transparent); }
.cat-image   { color: var(--c-image);   border-color: var(--c-image);   background: color-mix(in srgb, var(--c-image) 10%, transparent); }
.cat-video   { color: var(--c-video);   border-color: var(--c-video);   background: color-mix(in srgb, var(--c-video) 10%, transparent); }
.cat-audio   { color: var(--c-audio);   border-color: var(--c-audio);   background: color-mix(in srgb, var(--c-audio) 10%, transparent); }
.cat-pdf     { color: var(--c-pdf);     border-color: var(--c-pdf);     background: color-mix(in srgb, var(--c-pdf) 10%, transparent); }
.cat-archive { color: var(--c-archive); border-color: var(--c-archive); background: color-mix(in srgb, var(--c-archive) 10%, transparent); }
.cat-apk     { color: var(--c-apk);     border-color: var(--c-apk);     background: color-mix(in srgb, var(--c-apk) 10%, transparent); }
.cat-bin     { color: var(--c-bin);     border-color: var(--c-bin);     background: color-mix(in srgb, var(--c-bin) 10%, transparent); }

/* ---- file list ------------------------------------------- */

.filelist { border: 1px solid var(--line); background: var(--panel); }
.filerow {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto auto auto;
  gap: 16px; align-items: center;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; transition: background 0.12s;
  animation: rise 0.35s both;
}
.filerow:nth-child(1) { animation-delay: 0.00s; }
.filerow:nth-child(2) { animation-delay: 0.03s; }
.filerow:nth-child(3) { animation-delay: 0.06s; }
.filerow:nth-child(4) { animation-delay: 0.09s; }
.filerow:nth-child(5) { animation-delay: 0.12s; }
.filerow:nth-child(6) { animation-delay: 0.15s; }
.filerow:nth-child(7) { animation-delay: 0.18s; }
.filerow:nth-child(8) { animation-delay: 0.21s; }
.filerow:nth-child(n+9) { animation-delay: 0.24s; }
.filerow:last-child { border-bottom: 0; }
.filerow:hover { background: var(--panel2); }
.filerow:hover .fname { color: var(--amber-hi); }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fproj { font-size: 11px; color: var(--dim); border: 1px solid var(--line); padding: 2px 8px; }
.fsize { font-size: 11px; color: var(--dim); text-align: right; min-width: 64px; }
.ftime { font-size: 11px; color: var(--faint); text-align: right; min-width: 76px; }

/* ---- project grid ---------------------------------------- */

.projgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.projcard {
  position: relative;
  border: 1px solid var(--line); background: var(--panel); padding: 20px;
  transition: border-color 0.15s, transform 0.15s;
  animation: rise 0.4s both;
}
.projcard:nth-child(2) { animation-delay: 0.04s; }
.projcard:nth-child(3) { animation-delay: 0.08s; }
.projcard:nth-child(4) { animation-delay: 0.12s; }
.projcard:nth-child(n+5) { animation-delay: 0.16s; }
.projcard:hover { border-color: var(--line2); transform: translateY(-2px); }
.projcard::before, .projcard::after {
  content: ""; position: absolute; width: 12px; height: 12px;
  border: 0 solid var(--amber); opacity: 0; transition: opacity 0.15s;
}
.projcard::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.projcard::after { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }
.projcard:hover::before, .projcard:hover::after { opacity: 1; }
.projicon { color: var(--amber); font-size: 18px; margin-bottom: 14px; }
.projname { font-weight: 700; font-size: 15px; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projmeta { font-size: 11px; color: var(--dim); }
.projtime { font-size: 10px; letter-spacing: 0.08em; color: var(--faint); margin-top: 6px; }

/* ---- toolbar / dropzone ---------------------------------- */

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.dropzone {
  border: 1px dashed var(--line2); color: var(--faint);
  font-size: 11px; letter-spacing: 0.12em; text-align: center;
  padding: 18px; margin-bottom: 18px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--amber); color: var(--amber); background: var(--amber-glow); }
.upload-note {
  border: 1px solid var(--amber); color: var(--amber); background: var(--amber-glow);
  font-size: 11px; letter-spacing: 0.18em; text-align: center;
  padding: 12px; margin-bottom: 18px;
  animation: pulse 1.2s infinite;
}

/* ---- empty state ----------------------------------------- */

.empty {
  border: 1px dashed var(--line2); color: var(--faint);
  text-align: center; padding: 38px 20px;
  font-size: 11px; letter-spacing: 0.18em;
}

/* ---- note editor ----------------------------------------- */

.editor-form { border: 1px solid var(--line); background: var(--panel); animation: rise 0.35s both; }
.editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line);
}
.editor-left { display: flex; align-items: center; gap: 14px; }
.editor-left .field-label { margin: 0; }
.dirty { font-size: 11px; color: var(--amber); }
#editor {
  display: block; width: 100%; min-height: 58vh; resize: vertical;
  border: 0; background: var(--input); padding: 18px;
  font-size: 13px; line-height: 1.7;
}
#editor:focus { box-shadow: none; }

/* ---- previews -------------------------------------------- */

.preview {
  border: 1px solid var(--line); background: var(--panel);
  display: flex; justify-content: center; padding: 16px;
  animation: rise 0.35s both;
}
.preview img { max-width: 100%; max-height: 70vh; }
.preview video { width: 100%; max-height: 70vh; }
.preview-pad { padding: 44px 24px; }
.preview audio { width: 100%; max-width: 620px; }
.preview-tall { padding: 0; }
.preview-tall iframe { width: 100%; height: 75vh; border: 0; background: #fff; }

.codeview {
  border: 1px solid var(--line); background: var(--input);
  overflow: auto; max-height: 70vh; animation: rise 0.35s both;
}
.codeview pre {
  padding: 20px; font-family: var(--mono); font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}

.binpanel {
  border: 1px solid var(--line); background: var(--panel);
  padding: 56px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: var(--dim); font-size: 12px; letter-spacing: 0.12em;
  animation: rise 0.35s both;
}
.binicon { font-size: 34px; color: var(--amber); }

.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  margin-top: 18px;
}
.meta { background: var(--panel); padding: 12px 16px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.meta .field-label { margin: 0 0 6px; }
.meta a:hover { color: var(--amber); }

/* ---- dialogs --------------------------------------------- */

.dlg { margin: auto; border: 1px solid var(--line2); background: var(--panel); color: var(--text); padding: 0; width: min(560px, 92vw); }
.dlg::backdrop { background: rgba(6, 8, 11, 0.72); backdrop-filter: blur(3px); }
.dlg form { padding: 24px; }
.dlg h3 { font-size: 12px; letter-spacing: 0.24em; color: var(--amber); }
.dlg h3::before { content: "▚ "; color: var(--faint); }
.dlg textarea { min-height: 220px; resize: vertical; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---- login ----------------------------------------------- */

.login-body { justify-content: center; }
.login-wrap { width: min(400px, 92vw); margin: auto; padding: 40px 0; }
.login-card {
  position: relative;
  border: 1px solid var(--line); background: var(--panel); padding: 34px;
  animation: rise 0.45s both;
}
.login-card::before, .login-card::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 0 solid var(--amber);
}
.login-card::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.login-card::after { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }
.login-tag {
  display: inline-block; font-size: 10px; letter-spacing: 0.3em; color: var(--amber);
  border: 1px solid var(--line); border-left: 2px solid var(--amber);
  background: var(--panel2); padding: 6px 12px; margin-bottom: 22px;
}
.login-brand { font-size: 32px; letter-spacing: 0.04em; margin-bottom: 10px; }
.caret {
  display: inline-block; width: 0.55em; height: 1.02em;
  background: var(--amber); margin-left: 8px; vertical-align: -0.12em;
  animation: blink 1.1s steps(1) infinite;
}
.login-sub { font-size: 12px; color: var(--dim); margin-bottom: 22px; }
.login-form .field-label:first-child { margin-top: 0; }
.login-form .btn { margin-top: 24px; }
.login-foot { text-align: center; margin-top: 18px; font-size: 10px; letter-spacing: 0.22em; color: var(--faint); }

/* ---- responsive ------------------------------------------ */

@media (max-width: 640px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .mainnav a { padding: 6px 8px; letter-spacing: 0.1em; }
  .user-chip { display: none; }
  .wrap { width: calc(100% - 28px); }
  .filerow { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; }
  .fproj, .ftime { display: none; }
  .stats { width: 100%; }
  .stat { flex: 1; min-width: 0; padding: 10px 12px; }
  .inline-form { width: 100%; }
  .inline-form input { width: auto; flex: 1; }
  .foot { flex-direction: column; gap: 4px; }
}
