/* ============================================================
   应用布局：响应式 shell · 备忘录 · 详情 · 编辑器 · 管理端
   ============================================================ */

#app { height: 100dvh; }

/* ---- 主壳 ---- */
.shell { display: flex; height: 100dvh; overflow: hidden; }
.shell .main { display: flex; flex-direction: column; flex: 1; min-width: 0; height: 100%; }
.shell .content { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.nav-bar { display: none; }

@media (max-width: 839px) {
  .shell { flex-direction: column; }
  .nav-rail { display: none; }
  .nav-bar { display: flex; }
}

/* ---- 认证页 ---- */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--md-primary-container), transparent 60%), var(--md-surface); }
.auth-card { width: 100%; max-width: 440px; background: var(--md-surface-container-low); border-radius: var(--md-shape-xl);
  padding: 32px; box-shadow: var(--md-elev-2); --tf-bg: var(--md-surface-container-low); animation: auth-in var(--md-dur-4) var(--md-ease-decel); }
@keyframes auth-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-logo .logo-badge { width: 64px; height: 64px; border-radius: 20px; background: var(--md-primary); color: var(--md-on-primary);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--md-elev-2); }
.auth-logo .logo-badge .icon { width: 34px; height: 34px; }
.auth-logo h1 { margin: 0; font-size: 26px; font-weight: 500; }
.auth-logo p { margin: 0; color: var(--md-on-surface-variant); font-size: 14px; }
.auth-tabs { display: flex; background: var(--md-surface-container-highest); border-radius: var(--md-shape-full); padding: 4px; margin-bottom: 24px; }
.auth-tabs button { flex: 1; height: 40px; border: none; background: transparent; border-radius: var(--md-shape-full);
  font-size: 14px; font-weight: 500; color: var(--md-on-surface-variant); cursor: pointer; transition: all var(--md-dur-2) var(--md-ease); }
.auth-tabs button.active { background: var(--md-surface-container-lowest); color: var(--md-primary); box-shadow: var(--md-elev-1); }
.auth-field { margin-bottom: 16px; }
.auth-note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--md-shape-md); background: var(--md-surface-container);
  font-size: 13px; color: var(--md-on-surface-variant); line-height: 1.5; margin-top: 16px; }
.auth-note .icon { width: 20px; height: 20px; flex: none; color: var(--md-primary); }

/* 密钥展示 */
.key-reveal { background: var(--md-surface-container-highest); border-radius: var(--md-shape-md); padding: 16px; margin: 16px 0; }
.key-reveal .key-label { font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.key-reveal .key-value { font-family: var(--md-mono); font-size: 15px; word-break: break-all; line-height: 1.7; letter-spacing: 0.5px;
  background: var(--md-surface-container-lowest); padding: 12px; border-radius: var(--md-shape-sm); border: 1px dashed var(--md-outline); }
.key-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---- 备忘录工具栏 ---- */
.memo-toolbar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; flex: none; flex-wrap: wrap; }
.memo-toolbar .chip-row { flex: 1; min-width: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 2px; }
.memo-toolbar .chip-row::-webkit-scrollbar { display: none; }
.memo-count { font-size: 12px; color: var(--md-on-surface-variant); white-space: nowrap; }

/* ---- 虚拟列表容器 ---- */
.memo-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.memo-list-pad { padding: 0 8px 96px; }

/* 列表项 */
.memo-item { display: flex; align-items: center; gap: 12px; height: 100%; padding: 0 12px; cursor: pointer;
  border-radius: var(--md-shape-md); transition: background-color var(--md-dur-1) var(--md-ease); position: relative; }
.memo-item:hover { background: var(--md-surface-container-high); }
.memo-item.selected { background: var(--md-secondary-container); }
.memo-item .memo-check { flex: none; display: flex; align-items: center; }
.memo-type { width: 44px; height: 44px; border-radius: var(--md-shape-md); flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--md-surface-container-highest); color: var(--md-primary); overflow: hidden; position: relative; }
.memo-type img { width: 100%; height: 100%; object-fit: cover; }
.memo-type .icon { width: 22px; height: 22px; }
.memo-body { flex: 1; min-width: 0; }
.memo-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.memo-title .pin { color: var(--md-primary); width: 16px; height: 16px; flex: none; }
.memo-preview { font-size: 13px; color: var(--md-on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.memo-sub { font-size: 12px; color: var(--md-on-surface-variant); margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.memo-end { flex: none; display: flex; align-items: center; gap: 4px; color: var(--md-on-surface-variant); }

/* 网格 */
.memo-grid-row { display: grid; gap: 8px; height: 100%; align-content: stretch; }
.memo-cell { position: relative; border-radius: var(--md-shape-md); overflow: hidden; cursor: pointer;
  background: var(--md-surface-container-high); display: flex; flex-direction: column; transition: transform var(--md-dur-2) var(--md-ease), box-shadow var(--md-dur-2) var(--md-ease); }
.memo-cell:hover { box-shadow: var(--md-elev-2); transform: translateY(-2px); }
.memo-cell.selected { outline: 3px solid var(--md-primary); }
.memo-cell .cell-media { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--md-surface-container-highest); overflow: hidden; }
.memo-cell .cell-media img { width: 100%; height: 100%; object-fit: cover; }
.memo-cell .cell-media .icon { width: 40px; height: 40px; color: var(--md-on-surface-variant); opacity: 0.6; }
.memo-cell .cell-info { padding: 8px 10px; flex: none; }
.memo-cell .cell-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memo-cell .cell-sub { font-size: 11px; color: var(--md-on-surface-variant); margin-top: 2px; }
.memo-cell .cell-badge { position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 8px;
  background: rgba(0,0,0,0.5); color: #fff; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.memo-cell .cell-badge .icon { width: 16px; height: 16px; }
.memo-cell .cell-pin { position: absolute; top: 8px; right: 8px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }
.memo-cell .cell-check { position: absolute; bottom: 8px; right: 8px; }

/* ---- FAB ---- */
.fab-main { position: fixed; right: 24px; bottom: 24px; z-index: 30; }
@media (max-width: 839px) { .fab-main { bottom: 96px; right: 16px; } }

/* ---- 选择操作条 ---- */
.selection-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--md-secondary-container);
  color: var(--md-on-secondary-container); flex: none; animation: slide-down var(--md-dur-3) var(--md-ease); }
@keyframes slide-down { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
.selection-bar .count { font-weight: 500; flex: 1; }

/* ---- 详情视图 ---- */
.detail-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex: none; }
.detail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 32px; }
.detail-title-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.detail-title { font-size: 22px; font-weight: 500; flex: 1; min-width: 0; word-break: break-word; }
.detail-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--md-on-surface-variant); margin-bottom: 20px; }
.detail-meta span { display: inline-flex; align-items: center; gap: 4px; }
.detail-text { font-size: 15px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; background: var(--md-surface-container-low);
  padding: 20px; border-radius: var(--md-shape-md); }
.detail-media { display: flex; align-items: center; justify-content: center; background: var(--md-surface-container-lowest);
  border-radius: var(--md-shape-md); overflow: hidden; min-height: 200px; }
.detail-media img { max-width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.detail-media video { max-width: 100%; max-height: 70vh; display: block; }
.detail-loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 64px; color: var(--md-on-surface-variant); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

/* 图片灯箱 */
.lightbox { position: fixed; inset: 0; z-index: 1500; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--md-dur-3) var(--md-ease); }
.lightbox.show { opacity: 1; }
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 4px; }
.lightbox-bar { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.lightbox-bar .icon-btn { color: #fff; background: rgba(255,255,255,0.12); }

/* ---- 编辑器 ---- */
.editor-field { margin-bottom: 16px; }
.editor-drop { border: 2px dashed var(--md-outline); border-radius: var(--md-shape-md); padding: 32px; text-align: center;
  color: var(--md-on-surface-variant); cursor: pointer; transition: all var(--md-dur-2) var(--md-ease); }
.editor-drop:hover, .editor-drop.dragover { border-color: var(--md-primary); background: var(--md-primary-container); color: var(--md-on-primary-container); }
.editor-drop .icon { width: 40px; height: 40px; margin-bottom: 8px; }
.upload-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.upload-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--md-surface-container); border-radius: var(--md-shape-sm); }
.upload-item .icon { color: var(--md-primary); }
.upload-item .u-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.upload-item .u-size { font-size: 12px; color: var(--md-on-surface-variant); }
.upload-item .progress-linear { width: 80px; flex: none; }

/* ---- 设置页 ---- */
.settings-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.settings-group { max-width: 720px; margin: 0 auto 24px; }
.settings-group h3 { font-size: 13px; font-weight: 500; color: var(--md-primary); text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 8px; padding: 0 4px; }
.settings-card { background: var(--md-surface-container-low); border-radius: var(--md-shape-lg); overflow: hidden; }
.settings-row { display: flex; align-items: center; gap: 16px; padding: 16px; border-bottom: 1px solid var(--md-outline-variant); }
.settings-row:last-child { border-bottom: none; }
.settings-row .s-icon { width: 40px; height: 40px; border-radius: var(--md-shape-md); background: var(--md-surface-container-highest);
  display: flex; align-items: center; justify-content: center; color: var(--md-primary); flex: none; }
.settings-row .s-content { flex: 1; min-width: 0; }
.settings-row .s-title { font-size: 15px; font-weight: 500; }
.settings-row .s-sub { font-size: 13px; color: var(--md-on-surface-variant); margin-top: 2px; }
.account-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; text-align: center; }
.account-hero .avatar { width: 72px; height: 72px; border-radius: 24px; background: var(--md-primary-container); color: var(--md-on-primary-container);
  display: flex; align-items: center; justify-content: center; }
.account-hero .avatar .icon { width: 40px; height: 40px; }
.account-hero .acct-num { font-family: var(--md-mono); font-size: 18px; letter-spacing: 1px; }

/* ---- 锁屏 ---- */
.lock-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--md-surface); }

/* ============================================================
   管理端
   ============================================================ */
.admin-content { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; }
.admin-page { max-width: 1200px; margin: 0 auto; }
.admin-page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-page-head h2 { margin: 0; font-size: 26px; font-weight: 400; flex: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--md-surface-container-low); border-radius: var(--md-shape-lg); padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow var(--md-dur-2) var(--md-ease), transform var(--md-dur-2) var(--md-ease); }
.stat-card:hover { box-shadow: var(--md-elev-2); transform: translateY(-2px); }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: var(--md-shape-md); display: flex; align-items: center; justify-content: center; }
.stat-card .stat-value { font-size: 30px; font-weight: 500; line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: var(--md-on-surface-variant); }
.stat-card .stat-trend { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.panel { background: var(--md-surface-container-low); border-radius: var(--md-shape-lg); padding: 20px; margin-bottom: 24px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 17px; font-weight: 500; flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* 管理端移动端卡片替代表格 */
.mobile-cards { display: none; flex-direction: column; gap: 12px; }
.m-card { background: var(--md-surface-container-low); border-radius: var(--md-shape-md); padding: 16px; }
.m-card .m-row { display: flex; align-items: center; gap: 12px; }
.m-card .m-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .admin-content { padding: 16px; }
  .table-wrap.desktop-table { display: none; }
  .mobile-cards { display: flex; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }
}

/* 审计 / 日志 */
.audit-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--md-outline-variant); font-size: 13px; }
.audit-item:last-child { border-bottom: none; }
.audit-item .a-time { color: var(--md-on-surface-variant); white-space: nowrap; font-family: var(--md-mono); font-size: 12px; }
.audit-item .a-action { font-weight: 500; }
.audit-item .a-detail { color: var(--md-on-surface-variant); }

/* 机器人状态点 */
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.status-dot.ok { background: var(--md-success); box-shadow: 0 0 0 3px var(--md-success-container); }
.status-dot.err { background: var(--md-error); box-shadow: 0 0 0 3px var(--md-error-container); }
.status-dot.off { background: var(--md-outline); }

/* 系统信息键值 */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kv { background: var(--md-surface-container); border-radius: var(--md-shape-sm); padding: 12px 14px; }
.kv .k { font-size: 12px; color: var(--md-on-surface-variant); }
.kv .v { font-size: 15px; font-weight: 500; margin-top: 2px; word-break: break-all; }

/* 批量输入 */
.batch-area { width: 100%; min-height: 140px; font-family: var(--md-mono); font-size: 13px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
.pager .info { font-size: 13px; color: var(--md-on-surface-variant); }

/* 加载遮罩 */
.loading-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--md-surface); z-index: 50; }

/* 视图切换动画 */
.view-enter { animation: view-in var(--md-dur-3) var(--md-ease-decel); }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   响应式导航：桌面 = 高密度 rail + 表格；移动 = 汉堡 + 侧边抽屉
   ============================================================ */
.nav-toggle { display: none; }
@media (max-width: 839px) { .nav-toggle { display: inline-flex; } }

/* 移动端不使用底部导航（项多会溢出），改用侧边抽屉 */
.shell-admin .nav-bar, .shell-user .nav-bar { display: none !important; }
/* 用户端去掉底部导航后，FAB 回落到右下角 */
@media (max-width: 839px) { .shell-user .fab-main { bottom: 24px; right: 16px; } }

/* M3 模态导航抽屉（移动端侧边栏） */
.drawer-scrim { position: fixed; inset: 0; background: var(--md-scrim); z-index: 900; opacity: 0; pointer-events: none; transition: opacity var(--md-dur-3) var(--md-ease); }
.drawer-scrim.show { opacity: 1; pointer-events: auto; }
.nav-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 86vw); z-index: 901;
  background: var(--md-surface-container-low); color: var(--md-on-surface);
  border-radius: 0 var(--md-shape-lg) var(--md-shape-lg) 0; box-shadow: var(--md-elev-3);
  transform: translateX(-105%); transition: transform var(--md-dur-3) var(--md-ease);
  display: flex; flex-direction: column; padding: 12px; overflow-y: auto; overscroll-behavior: contain;
}
.drawer-scrim.show .nav-drawer { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 8px; }
.drawer-head .drawer-logo { width: 40px; height: 40px; border-radius: 12px; background: var(--md-primary); color: var(--md-on-primary); display: flex; align-items: center; justify-content: center; flex: none; }
.drawer-head .title { flex: 1; min-width: 0; font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-section { font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); padding: 10px 16px 4px; letter-spacing: .4px; }
.drawer-divider { height: 1px; background: var(--md-outline-variant); margin: 8px 4px; }
.nav-drawer-item {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 16px; width: 100%;
  border: none; background: none; border-radius: var(--md-shape-full); cursor: pointer; text-align: left;
  color: var(--md-on-surface-variant); font-size: 14px; font-weight: 500;
  transition: background-color var(--md-dur-2) var(--md-ease);
}
.nav-drawer-item .icon { width: 24px; height: 24px; }
.nav-drawer-item.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.nav-drawer-item.danger { color: var(--md-error); }
.drawer-foot { margin-top: auto; padding-top: 8px; }

/* 移动端整体收紧，避免横向溢出 */
@media (max-width: 600px) {
  .auth-wrap { padding: 16px; }
  .auth-card { padding: 24px 20px; }
  .auth-logo h1 { font-size: 22px; }
  .key-reveal .key-value { font-size: 14px; letter-spacing: .3px; }
  .admin-content { padding: 12px; }
  .admin-page-head { gap: 8px; margin-bottom: 16px; }
  .admin-page-head h2 { font-size: 22px; }
  .panel { padding: 16px; }
  .top-bar { padding: 0 8px; height: 56px; }
  .top-bar-title { font-size: 18px; }
  .memo-list-pad { padding: 0 4px 96px; }
}

/* 分段按钮在窄屏横向滚动，绝不撑破布局 */
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { white-space: nowrap; flex: none; }

/* 桌面高密度：表格更紧凑 */
@media (min-width: 840px) {
  .md-table th { padding: 10px 14px; }
  .md-table td { padding: 8px 14px; }
  .admin-content { padding: 20px 24px; }
}

/* ---- 广告位 ---- */
.ad-slot { position: relative; margin: 8px 16px 0; padding: 10px; border: 1px solid var(--md-outline-variant); border-radius: var(--md-shape-md); background: var(--md-surface-container-low); }
.ad-tag { position: absolute; top: -8px; left: 10px; font-size: 10px; letter-spacing: .5px; color: var(--md-on-surface-variant); background: var(--md-surface-container-highest); border-radius: 4px; padding: 1px 6px; }
.ad-row { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; }
.ad-row::-webkit-scrollbar { display: none; }
.ad-card { flex: none; width: 132px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--md-on-surface); border-radius: var(--md-shape-sm); overflow: hidden; background: var(--md-surface-container); }
.ad-card img { width: 100%; height: 74px; object-fit: cover; display: block; background: var(--md-surface-container-highest); }
.ad-card .ad-title { font-size: 12px; padding: 0 8px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-frame { width: 100%; min-height: 90px; border: none; border-radius: var(--md-shape-sm); background: transparent; display: block; }

/* Domain setup: keep long hosts and controls inside narrow mobile panels. */
.domain-page { min-width: 0; }
.domain-page .panel-head { flex-wrap: wrap; gap: 8px; }
.domain-page .panel-head h3 { flex: 1 1 140px; }
.domain-page .kv-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.domain-page .kv, .domain-page .tf, .domain-page .tf-box { min-width: 0; }
.domain-page .editor-field { display: flex; flex-direction: column; margin: 18px 0; }
.domain-page .tf-helper { display: block; margin-top: 6px; line-height: 1.5; }
.domain-page .segmented { display: flex; flex-wrap: wrap; height: auto; gap: 4px; border: 0; }
.domain-page .segmented button { flex: 1 1 120px; border: 1px solid var(--md-outline); border-radius: 12px; min-height: 44px; white-space: normal; }
.domain-page .auth-note { align-items: flex-start; line-height: 1.6; overflow-wrap: anywhere; }
.domain-page .auth-note > .icon { flex-shrink: 0; }
.domain-page .chip-row { flex-wrap: wrap; }
.domain-page .domain-advanced summary { cursor: pointer; padding: 8px 0; font-weight: 500; }
.domain-page .domain-advanced[open] summary { margin-bottom: 20px; }
.domain-page .domain-advanced .panel { padding: 0; border: 0; box-shadow: none; margin-top: 24px; }
.domain-page .mono { overflow-wrap: anywhere; }

.memo-toolbar .chip-row .chip { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 600px) {
  .memo-toolbar { gap: 8px; }
  .memo-toolbar .chip-row { flex: 1 0 100%; width: 100%; }
  .memo-toolbar .memo-count { margin-right: auto; }
}
.profile-editor { padding: 20px; display: grid; gap: 12px; min-width: 0; }
.profile-editor label { display: block; margin-bottom: 16px; }
.profile-editor .tf-input { margin-top: 6px; }
.profile-editor input[type=file] { width: 100%; min-width: 0; }
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.profile-avatar[hidden] { display: none; }
.public-profile { display: flex; align-items: center; gap: 10px; margin-top: 8px; overflow-wrap: anywhere; }
.public-profile .profile-avatar { width: 40px; height: 40px; }

/* Decorative pet never captures input, covers a viewport or creates resize loops. */
.site-pet {
  position: fixed; z-index: 15; pointer-events: none; user-select: none;
  right: max(12px, env(safe-area-inset-right)); bottom: max(100px, env(safe-area-inset-bottom));
  width: min(var(--pet-size, 120px), 22vw, calc(100vw - 32px));
  height: min(var(--pet-size, 120px), 22vw, 24vh); max-height: calc(100dvh - 120px);
  object-fit: contain; contain: layout style; filter: drop-shadow(0 3px 5px #0002);
}
.site-pet[hidden] { display: none; }
@media(max-height:300px) { .site-pet { display:none; } }
@media(prefers-reduced-motion:reduce) { .site-pet { display:none; } }
.theme-editor, .theme-options { min-width: 0; }
.theme-options { display: grid; gap: 16px; }
.theme-options p { margin: 0; line-height: 1.6; }
.theme-options input[type=file], .theme-options select { max-width:100%; min-width:0; }
.theme-options input[type=color] { width: 64px; height: 40px; border: 0; padding: 2px; }
.theme-preview { width: min(100%, 320px); max-height: 240px; object-fit: contain; border-radius:12px; background: repeating-conic-gradient(#ddd 0 25%,#fff 0 50%) 0 / 16px 16px; }
.theme-preview[hidden] { display:none; }
.theme-current { display:flex; flex-wrap:wrap; gap:16px; }
.theme-current figure { margin:0; max-width:100%; }

.acceleration-body { display:grid; gap:12px; min-width:0; }
.acceleration-field { display:grid; gap:6px; min-width:0; }
.acceleration-field[hidden] { display:none; }

.acceleration-field input[type=checkbox] { width:20px; height:20px; }
.acceleration .mono, .acceleration li { overflow-wrap:anywhere; }
.acceleration .kv { margin-top:8px; min-width:0; }
.acceleration li { margin-block:8px; line-height:1.6; }
.acceleration summary { cursor:pointer; }

/* Organization controls remain touch targets without disabling list scrolling. */
.site-logo { display:inline-flex; width:32px; height:32px; flex-shrink:0; }
.org-controls { display:flex; align-items:center; flex-shrink:0; }
.memo-cell .org-controls { position:absolute; right:4px; top:4px; border-radius:24px; background:var(--md-surface-container); }
.org-drag { touch-action:none; cursor:grab; user-select:none; -webkit-user-select:none; }
.org-target { outline:2px solid var(--md-primary); outline-offset:-2px; }
.org-ghost { position:fixed; left:0; top:0; margin:0; width:min(280px,calc(100vw - 16px)); height:72px; box-sizing:border-box; display:flex; align-items:center; gap:12px; padding:10px 12px; border:1px solid var(--md-outline-variant); border-radius:var(--md-shape-md); z-index:20000; pointer-events:none; box-shadow:0 6px 20px #0003; background:var(--md-surface-container); color:var(--md-on-surface); will-change:transform; overflow:hidden; user-select:none; }
.org-ghost-thumb { width:44px; height:44px; flex:none; display:flex; align-items:center; justify-content:center; overflow:hidden; border-radius:8px; color:var(--md-primary); }
.org-ghost-thumb img { width:100%; height:100%; object-fit:cover; }
.org-ghost-body { flex:1; min-width:0; }
.org-ghost-title,.org-ghost-sub { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.org-ghost-title { font-size:14px; font-weight:500; }
.org-ghost-sub { font-size:12px; color:var(--md-on-surface-variant); margin-top:4px; }
@media(max-width:599px) { .org-controls .icon-btn { width:36px; height:40px; } }

/* Admin data is untrusted in length (IPv6, errors and audit details).
   Wrap text, keep controls shrinkable, and confine table scrolling to its wrapper. */
.admin-content, .admin-page { min-width:0; }
.admin-page { width:100%; overflow-wrap:anywhere; }
.admin-page :is(.panel,.m-card,.m-row,.panel-head,.tf,.tf-box,.table-wrap,.kv,.two-col > *) { min-width:0; max-width:100%; }
.admin-page .table-wrap { width:100%; }
.admin-page .two-col { grid-template-columns:repeat(2,minmax(0,1fr)); }
.admin-page .kv-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr)); }
.admin-page :is(.mono,.a-action,.a-detail,.tf-helper,.auth-note) { overflow-wrap:anywhere; }
.admin-page .panel-head { flex-wrap:wrap; }
.admin-page .audit-item { display:grid; grid-template-columns:minmax(0,160px) minmax(0,180px) minmax(0,1fr); }
.admin-page .audit-item > * { min-width:0; overflow-wrap:anywhere; }
.admin-page .audit-item .a-time { white-space:normal; }
.admin-app .dialog { min-width:0; overflow-wrap:anywhere; }
.admin-app .dialog :is(.dialog-content,.tf,.tf-box) { min-width:0; max-width:100%; }
.admin-app :is(.admin-page,.dialog) :is(pre,textarea) { max-width:100%; white-space:pre-wrap; overflow-wrap:anywhere; }
.admin-app :is(.admin-page,.dialog) .tf-input { min-width:0; max-width:100%; }
@media(max-width:900px) { .admin-page .two-col { grid-template-columns:minmax(0,1fr); } }
@media(max-width:600px) { .admin-page .audit-item { grid-template-columns:minmax(0,1fr); gap:4px; } }

/* Entry verification must cover the shell independently of authentication state. */
.entry-gate { position:fixed; inset:0; z-index:900; overflow:auto; background:var(--md-surface); }
.entry-gate .auth-note { overflow-wrap:anywhere; }

/* Drive-inspired file workspace: own branding, existing encrypted operations only. */
.user-app .main { background:var(--md-surface-container-low); }
.user-app .content { background:var(--md-surface); }
.user-app .memo-item { border-radius:8px; border-bottom:1px solid var(--md-outline-variant); }
.user-app .memo-item:focus-visible,.menu-item:focus-visible { outline:2px solid var(--md-primary); outline-offset:-2px; }
.user-app .memo-cell { border:1px solid var(--md-outline-variant); }
.user-app .memo-sub { white-space:nowrap; overflow:hidden; }
.menu { max-width:calc(100vw - 16px); max-height:calc(100dvh - 24px); overflow:auto; }
.menu-item { min-height:44px; }
.menu-item[aria-disabled=true] { opacity:.5; cursor:default; }
.menu-item span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@media(min-width:1024px){
 .user-app .nav-rail { width:184px; flex-shrink:0; padding:16px 12px; }
 .user-app .nav-rail-item { flex-direction:row; font-size:14px; padding:8px; border-radius:28px; gap:12px; }
 .user-app .nav-rail-item .nav-indicator { width:32px; background:none; }
 .user-app .nav-rail-item.active { background:var(--md-secondary-container); }
 .user-app .content { margin:0 16px 16px 0; border-radius:20px; }
 .user-app .memo-toolbar { padding:12px 20px; }
}
@media(max-width:599px){.user-app .memo-item{gap:8px;padding:0 8px}.user-app .memo-sub{gap:4px;font-size:11px}.user-app .org-controls .icon-btn{width:32px}}
.theme-progress { width:100%; height:10px; accent-color:var(--md-primary); }

.calculator { max-width:380px; margin:8vh auto; padding:24px; border-radius:24px; background:var(--md-surface-container); }
.calc-display { width:100%; box-sizing:border-box; font-size:28px; text-align:right; border:0; border-radius:12px; padding:16px; background:var(--md-surface); color:var(--md-on-surface); }
.calc-keys { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin-top:16px; }
.calc-key { min-height:56px; border:0; border-radius:50%; background:var(--md-secondary-container); color:var(--md-on-secondary-container); font-size:22px; cursor:pointer; }
@media(max-width:420px){.calculator{margin:24px 12px;padding:16px}}

.workspace-new { display:none; }
.workspace-heading { display:flex;align-items:center;justify-content:space-between;gap:12px;padding:20px 20px 4px; }
.workspace-heading h1 { font-size:24px;font-weight:400;margin:0; }
.workspace-heading .muted { font-size:12px; }
@media(min-width:1024px){.workspace-new {display:flex;align-self:flex-start;margin:8px 0 20px;padding:18px;border-radius:16px;height:56px}.user-app .fab-main{display:none}}
@media(max-width:599px){.workspace-heading{padding:12px 16px 0}.workspace-heading h1{font-size:22px}}

.site-pet {pointer-events:auto;touch-action:none;cursor:grab;}
.site-pet:active{cursor:grabbing}
.site-pet:focus-visible{outline:2px solid var(--md-primary);border-radius:12px}
.create-actions{display:grid;gap:12px}.create-actions .btn{justify-content:flex-start;min-height:56px;font-size:16px}
.admin-page audio { display:block; width:100%; max-width:100%; margin-top:12px; }
.admin-page input[type=file] { max-width:100%; min-width:0; }
