/* Structural rules for native HTML templates; original MOMIKA styles remain intact. */
[hidden] {
  display: none !important;
}
body, #app, #app *, .modal, .modal *, .preview-header, .preview-header *, .preview-status, .preview-status * {
  font-family: "MiSans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif !important;
}

:root { --motion-jelly: 280ms; }
.upload-progress, .upload-progress * { font-family: "MiSans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif !important; }
.upload-progress {
  position:fixed; z-index:1100; inset:auto 20px 20px auto;
  width:min(440px, calc(100vw - 40px)); box-sizing:border-box; padding:20px;
  display:grid; gap:12px; border-radius:20px; color:var(--text);
  background:var(--bg); border:1px solid var(--glass-border); box-shadow:var(--surface-depth);
}
.upload-progress progress { width:100%; height:12px; accent-color:var(--brand); }
.upload-progress small { color:var(--muted); line-height:1.6; }
.nav-item .ico { position:relative; }
.nav-item.active[data-route="search"] .ico::after {
  content:""; position:absolute; width:56%; height:56%; left:10%; top:10%;
  border-radius:50%; background:currentColor; opacity:.24; pointer-events:none;
}
@media (prefers-reduced-motion: reduce) { .btn { transition-duration:0ms; } }
.preview-stage .md-body code { font-family: 'Cascadia Mono', Consolas, monospace; }
/* Quiet depth: thin reflections, short contact shadows, no colored selection glow. */
:root {
  --control-depth:
    inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 1px 2px rgba(77, 64, 53, 0.045),
    0 3px 8px rgba(77, 64, 53, 0.035);
  --surface-depth:
    inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 2px 3px rgba(77, 64, 53, 0.03),
    0 8px 22px rgba(77, 64, 53, 0.05);
  --field-recess:
    inset 0 5px 12px rgba(126, 116, 107, 0.12),
    inset 0 1px 3px rgba(112, 103, 95, 0.1),
    inset 0 -2px 1px rgba(255, 255, 255, 0.88), 0 1px 0 rgba(255, 255, 255, 0.8);
  --empty-field-fill: linear-gradient(180deg, #eeebe7, #f4f1ed);
}
[data-theme="dark"] {
  --control-depth:
    inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.18),
    0 3px 8px rgba(0, 0, 0, 0.13);
  --surface-depth:
    inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 2px 3px rgba(0, 0, 0, 0.15),
    0 8px 22px rgba(0, 0, 0, 0.2);
  --field-recess:
    inset 0 5px 12px rgba(0, 0, 0, 0.3), inset 0 1px 3px rgba(0, 0, 0, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.07), 0 1px 0 rgba(255, 255, 255, 0.04);
  --empty-field-fill: linear-gradient(180deg, #1c1b1c, #242224);
}
.panel,
.qcard,
.entry {
  box-shadow: var(--surface-depth);
}
.qcard:hover {
  box-shadow: var(--surface-depth);
}
.btn,
.att-item,
.preview-tools button,
.tool-download,
.tool-close {
  box-shadow: var(--control-depth);
}
.btn:hover {
  box-shadow:
    inset 0 0 0 100px rgba(128, 128, 128, 0.075),
    var(--control-depth);
}
.btn.primary {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 2px 3px rgba(43, 79, 125, 0.1),
    0 4px 10px rgba(43, 79, 125, 0.06);
}
.btn.primary:hover {
  box-shadow:
    inset 0 0 0 100px rgba(128, 128, 128, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 2px 5px rgba(43, 79, 125, 0.1);
}
.btn:active {
  box-shadow:
    inset 0 2px 4px rgba(64, 59, 54, 0.12),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}
.nav-item.active,
.seg button.on {
  box-shadow:
    var(--glass-highlight),
    0 1px 2px rgba(77, 64, 53, 0.05);
}
input[data-empty="true"],
select[data-empty="true"],
textarea[data-empty="true"] {
  background: var(--empty-field-fill);
  border-color: transparent;
  box-shadow: var(--field-recess);
}
input[data-empty],
select[data-empty],
textarea[data-empty] {
  transition: border-color 120ms ease;
}
input[data-empty="true"]:focus,
select[data-empty="true"]:focus,
textarea[data-empty="true"]:focus {
  border-color: rgba(10, 132, 255, 0.45);
  box-shadow: var(--field-recess);
}
input[data-empty="false"],
select[data-empty="false"],
textarea[data-empty="false"] {
  background: var(--input-surface);
  box-shadow: var(--control-depth);
}
.dropzone {
  background: var(--empty-field-fill);
  box-shadow: var(--field-recess);
}
.topbar .btn {
  box-shadow: var(--glass-highlight);
}
.toolbar .btn:hover {
  box-shadow:
    inset 0 0 0 100px rgba(128, 128, 128, 0.075),
    var(--glass-highlight);
}
.ui-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  vertical-align: -0.18em;
  background: center/contain no-repeat;
  opacity: 0.74;
}
.ui-icon > img {
  display: block;
  width: 100%;
  height: 100%;
}
.ui-icon.ready {
  background-image: none !important;
}
[data-theme="dark"] .ui-icon {
  filter: invert(1);
}
.btn.primary .ui-icon {
  filter: invert(1);
  opacity: 1;
}
.qcard .stats > span::before {
  display: none;
}
.qcard .stats .ui-icon {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}
.answered-pill .ui-icon {
  width: 12px;
  height: 12px;
  flex-basis: 12px;
}
.btn .ui-icon + span {
  min-width: 0;
}
.hero-note {
  overflow-wrap: anywhere;
}
.modal-box [data-slot="body"] {
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.availability-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.6;
}
.availability-bar > span {
  min-width: 0;
}
.availability-bar > button {
  flex: 0 0 auto;
}
.page-connect .hero {
  min-height: 0;
  padding: 30px 12px;
}
.auth-screen {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
}
.auth-screen > .hero {
  min-height: 100%;
  padding-top: max(32px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}
.auth-screen .hero-right {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.auth-screen .hero-logo {
  width: 256px;
  height: 256px;
  display: block;
  flex: 0 0 auto;
  z-index: 1;
  filter: none;
}
.auth-screen .hero-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.auth-screen .hero-left .halo {
  width: 256px;
  height: 256px;
  max-width: none;
  pointer-events: none;
  opacity: 0.24;
  filter: blur(24px);
  animation: none;
  border-radius: 0;
  background: url("../assets/logo-hd.webp") center / contain no-repeat;
  transform: scale(1.08);
}
[data-theme="dark"] .auth-screen .hero-left .halo {
  background: url("../assets/logo-hd.webp") center / contain no-repeat;
  opacity: 0.32;
}
@media (max-width: 767px) {
  .auth-screen .hero-logo {
    width: 184px;
    height: 184px;
  }
  .auth-screen .hero-left .halo {
    width: 184px;
    height: 184px;
    filter: blur(18px);
  }
}
@media (max-width: 360px), (max-height: 500px) {
  .auth-screen .hero-logo {
    width: 144px;
    height: 144px;
  }
  .auth-screen .hero-left {
    min-height: 0;
  }
  .auth-screen .hero-left .halo {
    width: 144px;
    height: 144px;
    filter: blur(14px);
  }
}
.hero-right > [data-step] {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.statusbar .grow {
  flex: 1;
}
.page-search form > .filterbar:first-child {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
}
.page-settings > .content-narrow > form.panel {
  margin: 0;
}
.content > .content-narrow {
  animation: none;
}
@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 767px) {
  .availability-bar {
    padding: 8px 14px;
    align-items: flex-start;
  }
  .availability-bar > button {
    max-width: 112px;
    white-space: normal;
  }
  .page-search form > .filterbar:first-child {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .page-search form > .filterbar:first-child > input {
    grid-column: 1 / -1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .content > .content-narrow {
    animation: none;
  }
}

/* Publishing becomes available only after every attachment is safely staged. */
.btn.primary:disabled { background: #d9dcdf; color: #858b93; border-color: transparent; box-shadow: none; opacity: 1; cursor: not-allowed; }
.file-upload-state { display: block; font-size: 12px; color: var(--muted, #6f7885); margin-top: 4px; }
.file-upload-bar { display: block; width: 100%; max-width: 280px; height: 5px; margin-top: 6px; accent-color: var(--accent, #0089ff); }
/* Application UI is not a document selection surface; editors retain normal selection. */
* { -webkit-user-select: none; user-select: none; }
input, textarea, [contenteditable="true"], [contenteditable="true"] *, [contenteditable="plaintext-only"], [contenteditable="plaintext-only"] * {
  -webkit-user-select: text; user-select: text;
}

/* Shared library: use the existing MOMIKA materials and controls. */
.page-files { display: flex; flex-direction: column; }
.file-library { width: min(1100px, 100%); margin: 0 auto; min-width: 0; flex: 1 0 auto; display: flex; flex-direction: column; }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.library-upload-area { margin-top: auto; padding-top: 24px; }
.library-drop-placeholder { box-sizing: border-box; width: 100%; min-height: 132px; border: 2px dashed #0a84ff; border-radius: var(--panel-radius, 24px); background: rgba(10, 132, 255, .065); pointer-events: none; }
.library-toolbar > [data-slot="summary"] { margin-left: auto; }
.top-uploader { flex-shrink: 0; }
.top-client { flex-shrink: 0; }
.top-client img { object-fit: contain; }
.library-file-icon { display: grid; place-items: center; flex-shrink: 0; width: 52px; height: 52px; border-radius: 16px; background: var(--brand-weak); color: var(--brand); }
.library-search { position: relative; flex: 1; max-width: 440px; }
.library-search > .ui-icon { position: absolute; width: 17px; height: 17px; left: 17px; top: 50%; transform: translateY(-50%); z-index: 1; pointer-events: none; }
.library-search input { width: 100%; padding-left: 45px; }
.library-toolbar > span { color: var(--text-2); font-size: 13px; }
.library-items { display: grid; gap: 14px; }
.library-file { display: flex; align-items: start; gap: 18px; margin: 0; min-width: 0; }
.library-file-body { flex: 1; min-width: 0; }
.library-file h2 { margin: 0 0 9px; font-size: 16px; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.library-meta { display: flex; flex-wrap: wrap; gap: 5px 16px; color: var(--text-2); font-size: 12px; }
.library-file details { margin: 12px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.5; }
.library-file summary { width: fit-content; cursor: pointer; }
.library-file dl { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px 12px; margin-bottom: 0; }
.library-file dd { margin: 0; overflow-wrap: anywhere; }
.library-download { flex-shrink: 0; }
.library-more { display: block; margin: 24px auto; }
.library-empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.library-transfers { list-style: none; padding: 0; margin: 0 0 24px; }
.library-transfers li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.library-transfers li > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; font-size: 13px; overflow-wrap: anywhere; }
.library-transfers strong { font-weight: 500; }
.library-transfers span { color: var(--text-2); }
.library-transfers progress { width: 100%; height: 5px; margin-top: 10px; accent-color: var(--brand); }
@media (max-width: 767px) {
  .library-toolbar { flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
  .library-search { max-width: none; flex-basis: 100%; }
  .library-file { gap: 12px; flex-wrap: wrap; }
  .library-file-icon { width: 36px; height: 36px; border-radius: 12px; }
  .library-file-body { flex-basis: calc(100% - 48px); }
  .library-download { margin-left: 48px; }
  .library-file .btn { min-height: 40px; }
  .top-uploader-text, .top-client-text { display: none; }
}

.library-toolbar .library-download { margin-left: 0; }
