:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #15171a;
  --muted: #737982;
  --line: #e1e4e8;
  --accent: #1f6feb;
  --accent-hover: #195fc9;
  --danger: #c93434;
  --shadow: 0 10px 30px rgba(25, 32, 45, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --surface: #181b1f;
    --surface-2: #20242a;
    --text: #edf0f3;
    --muted: #9ba2ab;
    --line: #30353d;
    --accent: #4c91f8;
    --accent-hover: #6aa3fa;
    --danger: #ee6666;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.shell { width: min(900px, calc(100% - 28px)); margin: 28px auto 60px; }
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
#clipboardInput { display: block; width: 100%; min-height: 190px; resize: vertical; border: 0; outline: 0; padding: 18px; color: var(--text); background: transparent; line-height: 1.65; font-size: 16px; }
#clipboardInput::placeholder { color: var(--muted); }
.toolbar { border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; }
.toolbar-left, .header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.button { border: 1px solid var(--accent); background: var(--accent); color: white; border-radius: 9px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 38px; }
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.button.secondary:hover { background: var(--surface-2); }
.button.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.status { min-height: 24px; padding: 0 16px 10px; color: var(--muted); font-size: 13px; }
.history { display: grid; gap: 10px; margin-top: 18px; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; box-shadow: var(--shadow); }
.text-preview { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; min-height: 24px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-action { border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 8px; text-decoration: none; white-space: nowrap; }
.empty { text-align: center; padding: 52px 0; color: var(--muted); }
.text-dialog { width: min(760px, calc(100% - 28px)); max-height: 85vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--surface); }
.text-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-head { display: flex; justify-content: flex-end; padding: 8px; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 28px; cursor: pointer; width: 40px; height: 40px; }
.text-dialog pre { margin: 0; padding: 4px 20px 20px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow: auto; font: inherit; line-height: 1.65; }
.dialog-actions { border-top: 1px solid var(--line); padding: 12px; display: flex; justify-content: flex-end; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--text); color: var(--surface); padding: 9px 15px; border-radius: 9px; opacity: 0; pointer-events: none; transition: .18s ease; z-index: 20; max-width: calc(100% - 30px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.admin-body { min-height: 100vh; }
.admin-shell { width: min(1180px, calc(100% - 28px)); margin: 28px auto 70px; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.login-card { width: min(430px, 100%); margin: 12vh auto 0; }
h1, h2 { margin-top: 0; }
h1 { font-size: 26px; margin-bottom: 8px; }
h2 { font-size: 18px; }
.admin-header { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; }
.admin-header p, .hint { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 17px; }
.stat strong { display: block; font-size: 24px; margin-top: 8px; }
.stat span { color: var(--muted); font-size: 13px; }
.admin-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label, .stack label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select { width: 100%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 10px 11px; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
.full-row { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; }
.geo-test { line-height: 1.65; margin-bottom: 14px; }
.geo-test .allowed { color: #16823b; }
.geo-test .denied { color: var(--danger); }
.rule-forms { display: grid; gap: 10px; margin: 16px 0; }
.inline-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; }
#ipRuleForm { grid-template-columns: 150px minmax(0, 1fr) auto; }
.rules-list { display: grid; gap: 8px; }
.rule-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 12px; background: var(--surface-2); border-radius: 9px; }
.section-title-row { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.wrap { flex-wrap: wrap; justify-content: flex-end; }
.admin-items { display: grid; gap: 8px; margin-top: 16px; }
.admin-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; }
.admin-item-content { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 5.2em; overflow: hidden; }
.admin-item small { display: block; color: var(--muted); margin-top: 4px; }
.narrow-card { max-width: 560px; }
.error-text { color: var(--danger); min-height: 22px; }

@media (max-width: 780px) {
  .shell, .admin-shell { width: min(100% - 18px, 100%); margin-top: 10px; }
  #clipboardInput { min-height: 160px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .inline-form, #ipRuleForm { grid-template-columns: 1fr; }
  .admin-header, .section-title-row { align-items: stretch; flex-direction: column; }
  .header-actions { flex-wrap: wrap; }
  .history-item { padding: 12px; }
}

/* v1.0.6 file groups, timestamps and image previews */
.history-content { min-width: 0; display: grid; gap: 6px; }
.item-time { color: var(--muted); font-size: 11px; line-height: 1.2; white-space: nowrap; }
.file-main { min-width: 0; display: flex; align-items: center; gap: 11px; }
.file-main-button { width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.file-info { min-width: 0; display: grid; gap: 5px; }
.file-meta { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.group-title { font-weight: 600; }
.thumb-button { width: 54px; height: 54px; flex: 0 0 54px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.history-thumb { display: block; width: 54px; height: 54px; object-fit: cover; }
.detail-time { color: var(--muted); font-size: 12px; line-height: 1.5; }
.text-dialog .detail-time { padding: 0 20px 8px; }
.modal-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.file-dialog { width: min(720px, calc(100% - 28px)); max-height: 86vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--surface); }
.dialog-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 8px 18px; border-bottom: 1px solid var(--line); }
.dialog-title-row h2 { margin: 0; font-size: 18px; }
.file-dialog-body { padding: 16px 18px; overflow: auto; max-height: 62vh; }
.field-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 7px; }
.selection-head { margin: 16px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.selection-list, .group-files-list { display: grid; gap: 7px; }
.selection-file, .group-file-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.selection-file-info { min-width: 0; }
.selection-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-file small, .group-file-row small { display: block; color: var(--muted); margin-top: 3px; }
.danger-text { color: var(--danger); }
.note-edit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.group-dialog .detail-time { margin: 12px 0; }
.group-file-main { min-width: 0; display: flex; align-items: center; gap: 10px; }
.image-dialog { width: min(920px, calc(100% - 28px)); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--surface); }
.image-preview-wrap { display: flex; align-items: center; justify-content: center; min-height: 180px; max-height: 72vh; padding: 4px 16px 14px; overflow: auto; }
.image-preview-wrap img { display: block; max-width: 100%; max-height: 68vh; object-fit: contain; }
.image-preview-name { color: var(--muted); font-size: 12px; text-align: center; padding: 0 16px 14px; overflow-wrap: anywhere; }
.drop-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(31, 111, 235, .14); border: 3px dashed var(--accent); pointer-events: none; display: flex; align-items: center; justify-content: center; }
.drop-overlay[hidden] { display: none; }
.drop-overlay div { padding: 18px 26px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--accent); font-size: 18px; font-weight: 600; }

@media (max-width: 780px) {
  .toolbar { align-items: stretch; }
  .toolbar-left { min-width: 0; }
  .toolbar .button { padding-left: 10px; padding-right: 10px; }
  .thumb-button, .history-thumb { width: 48px; height: 48px; }
  .thumb-button { flex-basis: 48px; }
  .note-edit-row { grid-template-columns: 1fr; }
  .selection-head { align-items: flex-start; }
}

/* v1.0.7 file-group detail page and download actions */
.item-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; flex-wrap: wrap; }
.item-action.downloading { opacity: .55; pointer-events: none; cursor: wait; }
.detail-page { margin-top: 22px; margin-bottom: 64px; }
.detail-topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.detail-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.detail-card h1 { margin-bottom: 6px; }
.detail-card h2 { margin: 0; }
.detail-card > .detail-time { margin-bottom: 18px; }
.detail-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.detail-files { display: grid; gap: 8px; }
.detail-file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.detail-file-size { display: block; color: var(--muted); margin-top: 4px; }

@media (max-width: 780px) {
  .item-actions { flex-direction: column; align-items: flex-end; }
  .detail-page { margin-top: 10px; }
  .detail-card { padding: 14px; }
  .detail-topbar { position: sticky; top: 0; z-index: 5; padding: 8px 0; background: var(--bg); }
  .detail-section-head { align-items: flex-start; }
}

/* v1.0.9 no-JS / legacy browser compatibility (lynx, w3m, old devices) */
[hidden] { display: none !important; }
dialog:not([open]), .modal-dialog:not([open]) { display: none; }
.noscript-note { margin: 0 0 12px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.upload-form { display: grid; gap: 8px; margin-top: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.upload-form .field-label { margin-bottom: 0; }
