/* ============================================================
   WorkLog 网页端样式
   设计语言沿用桌面端：浅灰底 + 白卡片 + 靛蓝主色

   颜色全部走变量：--bg 由用户偏好决定，其余表面色跟着它成组切换。
   --bg 亮度低于 .5 时，app.js 会给 <html> 打上 data-theme="dark"，
   下面的 [data-theme="dark"] 就地覆盖整套色板。所以这里不许再出现
   写死的白底/深字，否则深色主题下会漏出亮斑。
   ============================================================ */

:root {
    color-scheme: light;

    /* 用户可改的那一项 */
    --bg: #f4f5f7;

    /* 表面层：卡片 > 次级块 > 更深的槽 */
    --card: #ffffff;
    --surface-soft: #fafbfc;
    --surface-2: #f3f4f6;
    --surface-3: #eceef2;

    --border: #e5e7eb;
    --border-strong: #d5d9e0;
    --hairline: #eff1f4;

    --text: #111827;
    --text-soft: #6b7280;
    --text-faint: #9ca3af;
    --placeholder: #c2c8d2;
    --dot-idle: #d1d5db;
    --chevron: #9aa0aa;

    /* --primary 是强调色（文字/描边），--primary-fill 是实心按钮底色：
       深色主题下强调色要提亮才看得清，但按钮底不能跟着提亮，否则白字糊掉 */
    --primary: #4f46e5;
    --primary-fill: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --primary-border: #c7d2fe;
    --primary-text-soft: #7d7aec;

    --ok: #10b981;
    --ok-soft: #ecfdf5;
    --ok-border: #a7f3d0;
    --ok-text: #047857;

    --warn: #f59e0b;
    --warn-soft: #fffbeb;
    --warn-text: #b45309;

    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #b91c1c;

    --topbar-bg: rgba(255, 255, 255, .92);
    --toast-bg: #111827;
    --toast-text: #ffffff;
    --swatch-border: rgba(17, 24, 39, .10);
    --swatch-border-hover: rgba(17, 24, 39, .26);
    --shadow-ink: rgba(17, 24, 39, .10);

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
    --shadow-lg: 0 10px 30px rgba(17, 24, 39, .10);
}

/* ------------------------------------------------------------ 深色主题
   卡片/边框从 --bg 推出来（混一点白），这样用户选深空灰还是夜蓝，
   浮起来的卡片都会跟着同一色系，不会出现「深蓝底配灰白卡片」。
   color-mix 不支持时退回上面给的那一档固定值。 */

[data-theme="dark"] {
    color-scheme: dark;

    --card: #1e232e;
    --card: color-mix(in srgb, var(--bg) 92%, #ffffff);
    --surface-soft: color-mix(in srgb, var(--bg) 95%, #ffffff);
    --surface-2: color-mix(in srgb, var(--bg) 86%, #ffffff);
    --surface-3: color-mix(in srgb, var(--bg) 78%, #ffffff);

    --border: #343b49;
    --border: color-mix(in srgb, var(--bg) 85%, #ffffff);
    --border-strong: #4a5364;
    --border-strong: color-mix(in srgb, var(--bg) 78%, #ffffff);
    --hairline: color-mix(in srgb, var(--bg) 91%, #ffffff);

    --text: #e7eaf1;
    --text-soft: #a8b1c1;
    --text-faint: #7d8797;
    --placeholder: #5c6675;
    --dot-idle: #4a5262;
    --chevron: #7d8797;

    --primary: #a5b4fc;
    --primary-fill: #4f46e5;
    --primary-dark: #6366f1;
    --primary-soft: rgba(99, 102, 241, .20);
    --primary-border: rgba(129, 140, 248, .45);
    --primary-text-soft: #c7d2fe;

    --ok-soft: rgba(16, 185, 129, .15);
    --ok-border: rgba(16, 185, 129, .38);
    --ok-text: #6ee7b7;

    --warn-soft: rgba(245, 158, 11, .15);
    --warn-text: #fcd34d;

    --danger-soft: rgba(239, 68, 68, .16);
    --danger-border: rgba(239, 68, 68, .38);
    --danger-text: #fca5a5;

    --topbar-bg: rgba(18, 21, 28, .88);
    --toast-bg: #e7eaf1;
    --toast-text: #14171f;
    --swatch-border: rgba(255, 255, 255, .16);
    --swatch-border-hover: rgba(255, 255, 255, .38);
    --shadow-ink: rgba(0, 0, 0, .45);

    --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .50);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* Blazor 默认焦点框太抢眼，只给键盘导航留 outline */
:focus:not(:focus-visible) {
    outline: none;
}

/* FocusOnNavigate 会把焦点放到 h1 上，去掉黑框，键盘用户仍能看到 */
h1:focus {
    outline: none;
}

h1:focus-visible {
    outline: 2px solid var(--primary-border);
    outline-offset: 4px;
    border-radius: 4px;
}

::selection {
    background: var(--primary-border);
}

/* ------------------------------------------------------------ 框架 */

.app-shell {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 58px;
    flex: 0 0 auto;
    background: var(--topbar-bg);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -.2px;
    color: var(--text);
    text-decoration: none;
    flex: 0 0 auto;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(79, 70, 229, .3);
}

.nav {
    display: flex;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.nav a {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 13px;
    border-radius: 8px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 13.5px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 550;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 0 4px;
    height: 34px;
    border-radius: 999px;
    color: var(--text-soft);
    font-size: 13px;
    text-decoration: none;
    transition: background .15s;
}

.user-chip:hover {
    background: var(--surface-2);
}

.avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex: 0 0 auto;
}

.page {
    flex: 1 1 auto;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 20px 40px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.page-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 19px;
    font-weight: 620;
    letter-spacing: -.3px;
    margin: 0;
}

.page-sub {
    font-size: 12.5px;
    color: var(--text-faint);
}

.spacer {
    flex: 1 1 auto;
}

/* ------------------------------------------------------------ 按钮 */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}

.btn:hover:not(:disabled) {
    background: var(--surface-soft);
    border-color: var(--border-strong);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-fill);
    border-color: var(--primary-fill);
    color: #fff;
    font-weight: 550;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-soft);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: transparent;
    color: var(--text);
}

.btn-danger-text {
    border-color: transparent;
    background: transparent;
    color: var(--danger);
    padding: 0 8px;
    height: 28px;
    font-size: 12.5px;
}

.btn-danger-text:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: transparent;
}

.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12.5px;
    border-radius: 7px;
}

.btn-block {
    width: 100%;
    height: 42px;
    font-size: 14px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-soft);
}

/* ------------------------------------------------------------ 卡片 */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-pad {
    padding: 18px 20px;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px 0;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -.1px;
}

.card-hint {
    font-size: 11.5px;
    color: var(--text-faint);
}

.blk {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ------------------------------------------------------------ 表单 */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-soft);
}

.input,
.textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 9px 12px;
    transition: border-color .15s, box-shadow .15s;
}

.input {
    height: 40px;
}

.textarea {
    resize: none;
    line-height: 1.7;
    min-height: 96px;
    display: block;
}

.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary-border);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .10);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--placeholder);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .input {
    padding-right: 42px;
}

.eye-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.eye-btn:hover {
    background: var(--surface-2);
    color: var(--text-soft);
}

.field-error {
    font-size: 12.5px;
    color: var(--danger);
}

/* ------------------------------------------------------------ 提示条 */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    line-height: 1.5;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.alert-ok {
    background: var(--ok-soft);
    color: var(--ok-text);
    border: 1px solid var(--ok-border);
}

.alert-info {
    background: var(--surface-soft);
    color: var(--text-soft);
    border: 1px solid var(--border);
}

/* ------------------------------------------------------------ 状态点 */

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--dot-idle);
    flex: 0 0 auto;
}

.dot.dirty {
    background: var(--warn);
}

.dot.saved {
    background: var(--ok);
}

.dot.saving {
    background: var(--primary-fill);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .3;
    }
}

/* ------------------------------------------------------------ 日期切换 */

.date-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.date-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.2px;
    min-width: 0;
}

.date-today {
    font-size: 12px;
    color: var(--primary);
    background: var(--primary-soft);
    border: none;
    border-radius: 999px;
    padding: 2px 9px;
    margin-left: 6px;
    vertical-align: 1px;
}

/* ------------------------------------------------------------ 日报 */

.daily-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
}

.daily-grid .blk {
    flex: 1 1 0;
    min-height: 140px;
}

.daily-grid .blk:first-child {
    flex: 1.7 1 0;
}

.daily-grid .textarea {
    flex: 1 1 auto;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 10px 16px 14px;
    min-height: 80px;
}

.daily-grid .textarea:focus {
    box-shadow: none;
    background: var(--surface-soft);
}

/* ------------------------------------------------------------ 日志页（日报 + 周报） */

/* 整页占满视口宽度：左栏这周 7 天贴最左边，右栏填满剩下的空间。
   只挑这一页（:has 不支持时退回 1180 居中，不影响可用性），
   个人中心那些表单页仍然居中，不然一行字太长反而难读。 */
.page:has(.log-grid) {
    max-width: none;
}

.log-grid {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 14px;
    flex: 1 1 auto;
    min-height: 0;
}

.log-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

/* 右栏顶部那一条：视图切换 + 状态 + 操作按钮 */
.log-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.view-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-3);
    border-radius: 9px;
    flex: 0 0 auto;
}

.view-tab {
    height: 28px;
    padding: 0 15px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-soft);
    cursor: pointer;
    transition: background .15s, color .15s;
}

.view-tab:hover:not(.is-active) {
    color: var(--text);
}

.view-tab.is-active {
    background: var(--card);
    color: var(--text);
    font-weight: 550;
    box-shadow: 0 1px 2px var(--shadow-ink);
    cursor: default;
}

/* 左栏时间列表 */
.week-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
}

/* 未来那几天点不了，灰掉但别太糊 */
.week-item:disabled {
    opacity: .55;
    cursor: default;
}

.week-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 11px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: var(--card);
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    width: 100%;
}

.week-item:hover {
    border-color: var(--primary-border);
    background: var(--surface-soft);
}

.week-item.is-empty {
    background: var(--surface-soft);
    border-style: dashed;
}

.week-item.is-active {
    border-color: var(--primary-border);
    background: var(--primary-soft);
}

.week-item-head {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 3px;
}

.week-item-label {
    font-size: 12.5px;
    font-weight: 600;
}

.week-item-date {
    font-size: 11.5px;
    color: var(--text-faint);
}

.week-item-body {
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.week-item-empty {
    font-size: 12px;
    color: var(--placeholder);
    font-style: normal;
}

.weekly-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* 三块高度由内容决定，超出容器就整栏滚动，不压缩输入框 */
.weekly-right .blk {
    flex: 0 0 auto;
}

/* 内容超过上限后自己出滚动条，别把字裁掉还滚不动 */
.weekly-right .textarea {
    min-height: 110px;
    max-height: 440px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* ------------------------------------------------------------ 登录 / 注册 */

.auth-wrap {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 18px;
    background:
        radial-gradient(900px 500px at 50% -10%, var(--primary-soft) 0%, transparent 70%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    padding: 30px 28px 26px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-brand .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 15px;
}

.auth-brand-text {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -.4px;
}

.auth-title {
    font-size: 17px;
    font-weight: 620;
    margin: 0 0 4px;
    letter-spacing: -.2px;
}

.auth-desc {
    font-size: 12.5px;
    color: var(--text-faint);
    margin: 0 0 20px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-foot {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: var(--text-faint);
}

.auth-foot a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-foot a:hover {
    text-decoration: underline;
}

.server-line {
    margin-top: 14px;
    font-size: 11px;
    color: var(--placeholder);
    text-align: center;
    word-break: break-all;
}

.check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: var(--text-soft);
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.check input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ------------------------------------------------------------ 个人中心 */

.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.kv {
    display: flex;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px dashed var(--hairline);
    font-size: 13px;
    gap: 12px;
}

.kv:last-child {
    border-bottom: none;
}

.kv-k {
    color: var(--text-faint);
    width: 76px;
    flex: 0 0 auto;
    font-size: 12.5px;
}

.kv-v {
    color: var(--text);
    word-break: break-all;
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--primary-soft);
    color: var(--primary);
}

.badge-muted {
    background: var(--surface-2);
    color: var(--text-soft);
}

.badge-ok {
    background: var(--ok-soft);
    color: var(--ok-text);
}

.badge-warn {
    background: var(--warn-soft);
    color: var(--warn-text);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger-text);
}

/* ------------------------------------------------------------ 邀请码 */

.invite-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.tbl th {
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-faint);
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.tbl td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
}

table.tbl tr:last-child td {
    border-bottom: none;
}

table.tbl tbody tr:hover {
    background: var(--surface-soft);
}

.code-cell {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13.5px;
    letter-spacing: .6px;
    font-weight: 600;
}

.row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    white-space: nowrap;
}

/* ------------------------------------------------------------ 空状态 */

.empty-card {
    padding: 60px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.empty-title {
    font-size: 15px;
    font-weight: 600;
}

.empty-desc {
    font-size: 13px;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.loading-line {
    padding: 40px 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-faint);
}

/* ------------------------------------------------------------ 提示气泡 */

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(8px);
    background: var(--toast-bg);
    color: var(--toast-text);
    font-size: 12.5px;
    padding: 9px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    z-index: 60;
    max-width: calc(100vw - 40px);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Blazor 出错提示条 */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 12px 18px;
    background: var(--danger-soft);
    color: var(--danger-text);
    font-size: 13px;
    border-top: 1px solid var(--danger-border);
}

#blazor-error-ui .reload {
    color: var(--danger-text);
    margin-left: 10px;
    font-weight: 600;
}

/* ------------------------------------------------------------ 平板与手机 */

@media (max-width: 900px) {
    .topbar {
        height: auto;
        padding: 8px 14px 0;
        flex-wrap: wrap;
        gap: 10px;
    }

    .brand {
        order: 1;
    }

    .topbar-right {
        order: 2;
        margin-left: auto;
    }

    .nav {
        order: 3;
        flex-basis: 100%;
        overflow-x: auto;
        gap: 2px;
        padding-bottom: 8px;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .nav a {
        padding: 0 11px;
        height: 32px;
        font-size: 13px;
    }

    .user-chip .user-name {
        display: none;
    }

    .page {
        padding: 14px 12px 28px;
    }

    .page-title {
        font-size: 17px;
    }

    .log-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .week-list {
        max-height: 240px;
    }

    .log-toolbar .page-sub {
        display: none;
    }

    .profile-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .invite-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invite-form .btn {
        grid-column: 1 / -1;
    }

    /* 手机上每块至少 150px，别把输入框压扁 */
    .daily-grid .blk,
    .daily-grid .blk:first-child,
    .weekly-right .blk {
        flex: 0 0 auto;
        min-height: 150px;
    }

    .daily-grid .textarea,
    .weekly-right .textarea {
        min-height: 110px;
    }

    .auth-card {
        padding: 24px 20px 20px;
        border-radius: 16px;
    }
}

@media (max-width: 560px) {
    .invite-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .date-title {
        font-size: 14px;
    }

    .page-sub {
        display: none;
    }
}

/* 打印周报时把按钮和左栏去掉，直接出一张干净的纸。
   深色主题下打印必须强行拉回浅色，不然白纸上是墨块 + 浅灰字 */
@media print {
    .topbar,
    .nav,
    .btn,
    .week-list,
    .status {
        display: none !important;
    }

    .log-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    body {
        background: #ffffff;
    }

    [data-theme="dark"] {
        --card: #ffffff;
        --surface-soft: #f7f8fa;
        --surface-2: #f3f4f6;
        --surface-3: #eceef2;
        --border: #dedfe3;
        --border-strong: #d5d9e0;
        --hairline: #eff1f4;
        --text: #111827;
        --text-soft: #4b5563;
        --text-faint: #6b7280;
    }

    .card {
        box-shadow: none;
        border-color: #ddd;
        break-inside: avoid;
    }
}

/* ------------------------------------------------------------
   登录 / 注册中转页（真正的中转，不是表单）
   ------------------------------------------------------------ */
.auth-redirect {
    width: 100%;
    max-width: 400px;
    padding: 40px 28px;
    text-align: center;
    color: var(--text-soft);
}

.auth-redirect-mark {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: var(--primary-fill);
    color: #fff;
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 18px;
}

.auth-redirect p {
    margin: 0;
    font-size: 14px;
}

.auth-redirect-sub {
    margin-top: 8px !important;
    font-size: 12.5px !important;
    color: var(--text-faint);
}

.auth-redirect-sub a {
    color: var(--primary);
}

/* ------------------------------------------------------------
   个人中心：左侧分区 + 右侧面板
   ------------------------------------------------------------ */
.settings {
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr);
    gap: 36px;
    align-items: start;
    max-width: 940px;
}

.settings-nav {
    position: sticky;
    top: 84px;
}

.settings-head h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 650;
    letter-spacing: -.01em;
    color: var(--text);
}

.settings-head p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-faint);
}

.settings-list {
    display: grid;
    gap: 2px;
    margin-top: 18px;
}

.settings-item {
    display: block;
    width: 100%;
    text-align: left;
    font-family: inherit;
    background: transparent;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0 8px 8px 0;
    padding: 9px 12px 10px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.settings-item:hover {
    background: var(--surface-soft);
}

.settings-item.is-active {
    background: var(--primary-soft);
    border-left-color: var(--primary);
}

.si-title {
    display: block;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-soft);
    line-height: 1.4;
}

.si-sub {
    display: block;
    font-size: 11.5px;
    color: var(--text-faint);
    line-height: 1.5;
    margin-top: 1px;
}

.settings-item.is-active .si-title {
    color: var(--primary);
    font-weight: 600;
}

.settings-item.is-active .si-sub {
    color: var(--primary-text-soft);
}

.settings-body {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 28px 30px;
    min-height: 380px;
}

.panel-head {
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 22px;
}

.panel-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
    color: var(--text);
}

.panel-head p {
    margin: 5px 0 0;
    font-size: 12.5px;
    color: var(--text-faint);
    line-height: 1.6;
}

.panel-form .field {
    margin-bottom: 16px;
}

.panel-form .label {
    font-size: 12.5px;
    color: var(--text-soft);
    margin-bottom: 7px;
}

/* 输入框右侧的「显示 / 隐藏」 */
.eye-btn.eye-text {
    width: auto;
    padding: 0 8px;
    font-family: inherit;
    font-size: 12px;
    height: 26px;
    border-radius: 6px;
}

.input-wrap .input {
    height: 40px;
}

.submit-wide {
    width: 100%;
    height: 40px;
    margin-top: 8px;
}

/* 账号信息 */
.settings-rows {
    display: grid;
}

.settings-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--hairline);
    font-size: 13.5px;
}

.settings-row:last-child {
    border-bottom: 0;
}

.sr-key {
    flex: 0 0 108px;
    color: var(--text-faint);
    font-size: 12.5px;
}

.sr-value {
    color: var(--text);
    word-break: break-all;
}

/* 偏好设置：背景色 */
.prefs-block .field {
    margin-bottom: 18px;
}

.prefs-block .label {
    font-size: 12.5px;
    color: var(--text-soft);
}

.swatches {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.swatch {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    /* 整块就是那个颜色：白底上放个小圆点，浅色根本看不出差别。
       --sw-fg / --sw-fg-strong 由页面按该色块的亮度算好传进来——
       深色预设上用深灰字会看不见，所以字色不能跟着主题走，只能跟着色块走 */
    background: var(--sw);
    border: 1px solid var(--swatch-border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--sw-fg, var(--text-soft));
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, box-shadow .15s, color .15s;
}

.swatch:hover:not(:disabled) {
    border-color: var(--swatch-border-hover);
}

.swatch.is-active {
    border-color: var(--primary);
    color: var(--sw-fg-strong, var(--primary));
    font-weight: 550;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}

.swatch:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.prefs-custom {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.color-input {
    width: 48px;
    height: 32px;
    padding: 2px 3px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    cursor: pointer;
}

.prefs-hint {
    font-size: 12px;
    color: var(--text-faint);
}

.prefs-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.prefs-state {
    font-size: 12.5px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

/* 邀请码面板 */
.gen-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
}

.gen-grid .field {
    margin-bottom: 4px;
}

.gen-grid .label {
    font-size: 12.5px;
    color: var(--text-soft);
    margin-bottom: 7px;
}

.gen-grid .input {
    height: 38px;
}

.block-btn {
    width: 100%;
    height: 40px;
    margin-top: 16px;
}

.section-hint {
    margin-top: 10px;
    font-size: 11.5px;
    color: var(--text-faint);
    line-height: 1.6;
}

.list-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 24px 0 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.list-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.list-meta {
    font-size: 12px;
    color: var(--text-faint);
}

.empty-line {
    padding: 26px 0 10px;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-faint);
}

.settings-redirect {
    padding: 60px 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-faint);
}

@media (max-width: 760px) {
    .settings {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .settings-nav {
        position: static;
    }

    .settings-list {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        margin-top: 14px;
        padding-bottom: 2px;
    }

    .settings-item {
        border-left: 0;
        border-bottom: 2px solid transparent;
        border-radius: 8px 8px 0 0;
        white-space: nowrap;
        padding: 8px 12px;
    }

    .settings-item.is-active {
        border-left-color: transparent;
        border-bottom-color: var(--primary);
    }

    .si-sub {
        display: none;
    }

    .settings-body {
        padding: 20px 18px 24px;
        min-height: 0;
    }

    .gen-grid {
        grid-template-columns: 1fr;
    }

    .swatches {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sr-key {
        flex-basis: 88px;
    }
}

/* FocusOnNavigate 会把焦点落到标题上，个人中心这个是纯展示标题，
   不属于键盘可达元素，别让它套一圈焦点框 */
.settings-head h1:focus,
.settings-head h1:focus-visible {
    outline: none;
}

/* ------------------------------------------------------------
   个人中心：贴左排版 + 邀请朋友
   ------------------------------------------------------------ */

/* 其他页面（日报/周报）保持居中，个人中心按截图整体靠左 */
.page:has(.settings) {
    max-width: none;
}

.settings {
    max-width: 1120px;
    margin: 0;
}

/* 生成邀请码：一行两个下拉 + 按钮 */
.gen-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

/* 下拉 + 按钮装进一个卡片里，和截图一致 */
.gen-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    background: var(--card);
}

.gen-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gen-label {
    font-size: 12px;
    color: var(--text-soft);
}

.select {
    height: 36px;
    min-width: 108px;
    padding: 0 30px 0 11px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background-color: var(--card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--chevron) 50%),
                      linear-gradient(135deg, var(--chevron) 50%, transparent 50%);
    background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.select:hover {
    border-color: var(--border-strong);
}

.select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.gen-btn {
    height: 36px;
    padding: 0 18px;
    font-size: 13px;
}

.gen-hint {
    margin: 12px 0 0;
    font-size: 11.5px;
    color: var(--text-faint);
    line-height: 1.7;
}

.gen-hint b {
    color: var(--text-soft);
    font-weight: 600;
}

/* 邀请码表：跟截图一样紧凑一点 */
.invite-tbl th {
    font-size: 11.5px;
    color: var(--text-faint);
    font-weight: 500;
    background: var(--surface-soft);
}

.invite-tbl td {
    font-size: 12.5px;
}

.invite-tbl .code-cell {
    font-weight: 600;
    letter-spacing: .06em;
}

/* 栅格子项默认 min-width:auto，会被表格/下拉撑破，窄屏必须放开 */
.settings-nav,
.settings-body,
.invite-panel {
    min-width: 0;
}

.table-wrap {
    max-width: 100%;
}

@media (max-width: 760px) {
    .settings {
        width: 100%;
    }

    .select {
        min-width: 92px;
    }

    .gen-btn {
        flex: 1 1 auto;
    }

    .list-head {
        gap: 8px;
    }
}

/* 窄屏别把列挤成两行，交给外层横向滚动 */
.invite-tbl {
    min-width: 520px;
}

.invite-tbl th,
.invite-tbl td {
    white-space: nowrap;
}

/* ============================================================
   项目模块（/projects）
   三栏：项目列表 · 信息卡列表 · 编辑器。
   颜色一律走变量，深色主题下不另写一套——这里的底色全部是
   --card / --surface-* / --text*，没有硬编码的白底深字。
   ============================================================ */

.page:has(.proj-grid) {
    max-width: 1480px;
}

.proj-grid {
    display: grid;
    grid-template-columns: 224px 318px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    min-height: 0;
}

.proj-col {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}

/* ------------------------------------------------------------ 左栏：项目 */

.proj-side {
    padding: 10px 9px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - 170px);
    overflow-y: auto;
}

.side-search {
    position: relative;
    margin: 2px 2px 8px;
}

.side-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-faint);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.side-search-clear:hover {
    background: var(--surface-2);
    color: var(--text);
}

.side-hint {
    padding: 0 8px 6px;
    font-size: 11px;
    line-height: 1.55;
    color: var(--text-faint);
}

.side-group {
    padding: 8px 8px 5px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--text-faint);
}

.side-empty {
    padding: 8px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-faint);
}

.side-toggle {
    margin-top: 6px;
    padding: 8px;
    border: 0;
    border-top: 1px solid var(--hairline);
    background: transparent;
    color: var(--text-faint);
    font-family: inherit;
    font-size: 11px;
    text-align: left;
    cursor: pointer;
}

.side-toggle:hover {
    color: var(--text-soft);
}

.proj-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.proj-item:hover {
    background: var(--surface-2);
}

.proj-item.is-active {
    background: var(--primary-soft);
    border-color: var(--primary-border);
}

.proj-item.is-archived {
    opacity: .66;
}

.proj-avatar {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent, var(--primary-fill));
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
}

.proj-item-main {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1 1 auto;
}

.proj-item-name {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proj-item-meta {
    font-size: 10.5px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

.pin-mark {
    flex: 0 0 auto;
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--warn-soft);
    color: var(--warn-text);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
}

/* ------------------------------------------------------------ 中栏：卡片列表 */

.proj-list {
    padding: 13px 13px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 170px);
    overflow-y: auto;
}

.proj-list-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.proj-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 15px;
    font-weight: 620;
    letter-spacing: -.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-desc {
    padding: 7px 10px;
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
}

.list-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--hairline);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.list-filters-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.kind-tag {
    flex: 0 0 auto;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.4;
}

.kind-note {
    background: var(--surface-2);
    color: var(--text-soft);
}

.kind-todo {
    background: var(--ok-soft);
    border-color: var(--ok-border);
    color: var(--ok-text);
}

.kind-link {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary-text-soft);
}

.kind-decision {
    background: var(--warn-soft);
    color: var(--warn-text);
}

.kind-snippet {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--text-soft);
    font-family: inherit;
    font-size: 11.5px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}

.chip:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* 放在 .kind-* 之后：选中态要盖过类型色 */
.chip.is-active {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary);
    font-weight: 550;
}

.select-sm {
    height: 28px;
    min-width: 88px;
    padding: 0 24px 0 8px;
    font-size: 12px;
    background-position: calc(100% - 13px) 12px, calc(100% - 8px) 12px;
}

.input-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12.5px;
}

.textarea-sm {
    min-height: 66px;
    padding: 8px 10px;
    font-size: 13px;
}

.check-sm {
    font-size: 11.5px;
    color: var(--text-soft);
}

.card-rows {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.card-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.card-row:hover {
    background: var(--surface-soft);
    border-color: var(--border);
}

.card-row.is-active {
    background: var(--primary-soft);
    border-color: var(--primary-border);
}

.card-row.is-archived {
    opacity: .6;
}

.card-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.card-row-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-row-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--text-faint);
    word-break: break-word;
}

.card-row-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 10.5px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.tag-chip {
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--primary-soft);
    color: var(--primary-text-soft);
    font-size: 10.5px;
}

.proj-chip {
    padding: 1px 6px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 10.5px;
}

/* ------------------------------------------------------------ 右栏：编辑器 */

.proj-editor {
    display: flex;
    flex-direction: column;
    min-height: 400px;
    max-height: calc(100vh - 170px);
    overflow-y: auto;
}

.editor {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 13px 16px 14px;
    min-height: 0;
}

.editor-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.editor-tool {
    height: 26px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text-soft);
    font-family: inherit;
    font-size: 11.5px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.editor-tool:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text);
}

.editor-tool.is-on {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary);
    font-weight: 550;
}

.editor-tool.is-danger {
    color: var(--danger);
}

.editor-tool.is-danger:hover:not(:disabled) {
    background: var(--danger-soft);
}

.editor-tool:disabled {
    opacity: .38;
    cursor: not-allowed;
}

.card-title-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 19px;
    font-weight: 620;
    letter-spacing: -.3px;
    outline: none;
    transition: background .15s, border-color .15s, box-shadow .15s;
}

.card-title-input:hover {
    background: var(--surface-soft);
}

.card-title-input:focus {
    background: var(--card);
    border-color: var(--primary-border);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.card-title-input::placeholder {
    color: var(--placeholder);
    font-weight: 500;
}

.editor-meta {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 8px;
    padding: 0 2px;
}

.editor-hint {
    padding-left: 2px;
    font-size: 11.5px;
    color: var(--text-faint);
}

.editor-body {
    min-height: 300px;
    padding: 10px 12px;
    font-size: 13.5px;
    line-height: 1.75;
    resize: none;
    tab-size: 4;
}

/* 片段（代码/命令）用等宽字体，其它类型保持正文字体 */
.editor-body.is-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12.8px;
    line-height: 1.7;
}

.editor-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 9px;
    border-top: 1px solid var(--hairline);
    font-size: 11px;
    color: var(--text-faint);
}

.editor-saved {
    font-variant-numeric: tabular-nums;
}

.sep-dot {
    color: var(--text-faint);
}

.link-btn {
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-family: inherit;
    font-size: 12.5px;
    text-decoration: underline;
    cursor: pointer;
}

/* ------------------------------------------------------------ 弹窗 */

.modal-veil {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(17, 24, 39, .42);
    backdrop-filter: blur(2px);
}

[data-theme="dark"] .modal-veil {
    background: rgba(0, 0, 0, .58);
}

.modal {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(720px, 100%);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 17px 20px 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.modal-sm {
    width: min(452px, 100%);
}

.modal-wide {
    width: min(920px, 100%);
}

.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 620;
}

.modal-hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.65;
    color: var(--text-faint);
}

.modal-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.dot-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.dot-swatch {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--swatch-border);
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
}

.dot-swatch:hover {
    transform: scale(1.08);
}

.dot-swatch.is-active {
    border-color: var(--card);
    box-shadow: 0 0 0 2px var(--accent);
}

/* ------------------------------------------------------------ 历史版本 */

.history-grid {
    display: grid;
    grid-template-columns: 214px minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.history-item:hover {
    background: var(--surface-soft);
    border-color: var(--border);
}

.history-item.is-active {
    background: var(--primary-soft);
    border-color: var(--primary-border);
}

.history-time {
    font-size: 10.5px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.history-title {
    font-size: 12.5px;
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-preview {
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--text-faint);
}

.history-content {
    width: 100%;
    margin: 0;
    padding: 12px;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text);
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.72;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ------------------------------------------------------------ 响应式 */

@media (min-width: 981px) {
    .proj-col {
        position: sticky;
        top: 74px;
        /* 三栏撑到视口底部：内容少时也像个工作台，不会露出半截白板 */
        min-height: calc(100vh - 220px);
    }
}

@media (max-width: 1180px) {
    .proj-grid {
        grid-template-columns: 196px 286px minmax(0, 1fr);
    }
}

@media (max-width: 980px) {
    .proj-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .proj-side {
        max-height: 236px;
    }

    .proj-list {
        max-height: 340px;
    }

    .proj-editor {
        max-height: none;
    }

    .editor-body {
        min-height: 220px;
    }

    .history-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .history-list {
        max-height: 180px;
    }
}

/* ------------------------------------------------------------ 附件 */

.attach-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 9px;
    border-top: 1px solid var(--hairline);
}

.attach-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.attach-title {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-soft);
}

.attach-hint {
    font-size: 11px;
    color: var(--text-faint);
}

/* InputFile 渲染出来就是个 input[type=file]，藏掉，点击交给外层 label */
.attach-input {
    display: none;
}

.attach-panel .btn.is-busy {
    opacity: .6;
    pointer-events: none;
}

.attach-empty {
    padding: 10px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    font-size: 11.5px;
    color: var(--text-faint);
    text-align: center;
}

.attach-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attach-thumb {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 260px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
}

.attach-thumb-img {
    display: block;
    line-height: 0;
    border-radius: 7px;
    overflow: hidden;
    background: var(--surface-2);
}

.attach-thumb-img img {
    display: block;
    max-width: 100%;
    max-height: 200px;
    margin: 0 auto;
    object-fit: contain;
}

.attach-thumb-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 11px;
    color: var(--text-faint);
}

.attach-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
}

.attach-ext {
    flex: 0 0 auto;
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--surface-3);
    color: var(--text-soft);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
}

.attach-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.attach-name:hover {
    color: var(--primary);
    text-decoration: underline;
}

.attach-size {
    flex: 0 0 auto;
    font-size: 10.5px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.attach-x {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-faint);
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.attach-x:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ------------------------------------------------------------ 卡片拖拽排序 */

.card-row[draggable="true"] {
    cursor: grab;
}

.card-row[draggable="true"]:active {
    cursor: grabbing;
}

/* 拖起来的那张半透明，落点用内阴影画一条「插入线」 */
.card-row.is-dragging {
    opacity: .42;
}

.card-row.drag-over {
    border-color: var(--primary-border);
    box-shadow: inset 0 2px 0 var(--primary);
}

/* ------------------------------------------------------------ 账号卡 */

/* 比「笔记」深一档的标签色，和另外五种区分开 */
.kind-account {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: var(--text);
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 2px 2px 0;
}

/* 标签 · 输入框 · 复制按钮 三列，复制按钮宽度固定，输入框吃掉剩余空间 */
.acc-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.acc-label {
    font-size: 12px;
    font-weight: 550;
    color: var(--text-soft);
    text-align: right;
}

.acc-row .input {
    height: 34px;
    font-size: 13px;
}

/* 密码框里的「显示/隐藏」贴着输入框右边，和「复制」按钮错开 */
.acc-row .input-wrap .input {
    padding-right: 48px;
}

.acc-copy {
    height: 30px;
    padding: 0 11px;
    font-size: 12px;
}

.acc-tip {
    padding: 2px 2px 0;
    font-size: 11px;
    line-height: 1.65;
    color: var(--text-faint);
}
