:root {
    --page: #f4f7ff;
    --surface: #ffffff;
    --surface-2: #f8faff;
    --line: #dfe5f1;
    --line-strong: #cdd6e8;
    --text: #182033;
    --muted: #68738a;
    --muted-2: #97a1b5;
    --primary: #635bff;
    --primary-dark: #5147ed;
    --orange: #ff9f43;
    --cyan: #13b8a6;
    --pink: #f45fa1;
    --danger: #dc4d64;
    --shadow: 0 18px 50px rgba(50, 68, 112, .10);
    color-scheme: light;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(rgba(91, 107, 156, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(91, 107, 156, .045) 1px, transparent 1px),
        radial-gradient(circle at 8% 2%, rgba(99, 91, 255, .10), transparent 25%),
        radial-gradient(circle at 94% 14%, rgba(255, 159, 67, .11), transparent 23%),
        var(--page);
    background-size: 44px 44px, 44px 44px, auto, auto, auto;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
.ambient { position: fixed; pointer-events: none; border-radius: 999px; filter: blur(120px); opacity: .16; }
.ambient-one { width: 420px; height: 420px; right: -180px; top: -220px; background: #ffb86b; }
.ambient-two { width: 420px; height: 420px; left: -220px; bottom: -240px; background: #8078ff; }

.primary-button, .secondary-button, .danger-button, .danger-solid {
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-weight: 750;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.primary-button { color: #fff; background: linear-gradient(135deg, #756dff, var(--primary)); box-shadow: 0 9px 22px rgba(99,91,255,.22); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(99,91,255,.28); }
.secondary-button { color: #4c5870; border-color: var(--line); background: #fff; }
.secondary-button:hover { background: #f6f8fd; }
.danger-button { color: var(--danger); border-color: rgba(220,77,100,.22); background: #fff5f7; }
.danger-solid { color: #fff; background: var(--danger); }

.eyebrow { margin: 0 0 12px; color: var(--primary); font-size: 10px; font-weight: 900; letter-spacing: .18em; }

/* Login */
.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(390px, 540px) 1fr; position: relative; z-index: 2; }
.login-screen.is-hidden { display: none; }
.login-panel { padding: 9vh clamp(38px, 6vw, 82px); background: rgba(255,255,255,.92); border-right: 1px solid rgba(223,229,241,.8); backdrop-filter: blur(22px); display: flex; flex-direction: column; justify-content: center; }
.login-brand { margin-bottom: 42px; }
.login-brand span, .brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; color: #fff; background: linear-gradient(145deg, #827bff, #564ced); box-shadow: 0 12px 26px rgba(99,91,255,.24); font-weight: 900; }
.login-panel h1 { margin: 0; font-size: clamp(43px, 5vw, 65px); line-height: 1.03; letter-spacing: -.055em; }
.login-copy { max-width: 390px; margin: 20px 0 30px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.login-panel form { max-width: 390px; display: grid; gap: 18px; }
.login-button { width: 100%; min-height: 48px; }
.login-error { min-height: 16px; margin: -7px 0 -9px; color: var(--danger); font-size: 11px; }
.secure-note { margin-top: 24px; color: var(--muted-2); font-size: 10px; }
.secure-note span, .connection-state span { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(19,184,166,.1); }
.login-aside { position: relative; overflow: hidden; background: linear-gradient(145deg, #eef1ff 0%, #fff7ee 50%, #eafbf8 100%); }
.login-aside::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(99,91,255,.16) 1px, transparent 1px); background-size: 24px 24px; mask-image: linear-gradient(to bottom, #000, transparent 80%); }
.login-aside > p { position: absolute; right: 7%; bottom: 8%; z-index: 2; margin: 0; text-align: right; color: rgba(54,61,88,.20); font-size: clamp(35px, 5vw, 68px); line-height: .92; letter-spacing: -.06em; font-weight: 900; }
.login-aside > p em { color: rgba(99,91,255,.45); font-style: normal; }
.orbit { position: absolute; z-index: 1; left: 50%; top: 42%; border: 1px solid rgba(99,91,255,.18); border-radius: 50%; transform: translate(-50%,-50%); }
.orbit-one { width: 410px; height: 410px; }
.orbit-two { width: 620px; height: 620px; border-style: dashed; }
.spark-card { position: absolute; z-index: 2; width: 150px; min-height: 94px; padding: 18px; border: 1px solid rgba(255,255,255,.86); border-radius: 17px; background: rgba(255,255,255,.76); backdrop-filter: blur(16px); box-shadow: 0 20px 55px rgba(68,77,118,.13); }
.spark-card b, .spark-card span { display: block; }
.spark-card b { color: var(--primary); font-size: 10px; letter-spacing: .15em; }
.spark-card span { margin-top: 20px; font-size: 13px; font-weight: 800; }
.spark-one { left: 20%; top: 25%; transform: rotate(-6deg); }
.spark-two { left: 53%; top: 43%; transform: rotate(4deg); }
.spark-three { left: 28%; top: 62%; transform: rotate(-2deg); }

/* App header */
.app-shell { min-height: 100vh; position: relative; z-index: 2; }
.app-shell.is-locked { display: none; }
.topbar { position: sticky; top: 0; z-index: 15; min-height: 76px; padding: 12px max(24px, calc((100vw - 1440px) / 2)); display: flex; align-items: center; gap: 28px; border-bottom: 1px solid rgba(215,222,237,.86); background: rgba(255,255,255,.88); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; flex: 0 0 auto; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 13px; }
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; margin-top: 2px; color: var(--muted-2); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.side-nav { display: flex; gap: 6px; min-width: 0; }
.nav-item { display: flex; align-items: center; gap: 7px; padding: 9px 12px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; white-space: nowrap; }
.nav-item:hover { color: var(--primary); background: #f0efff; }
.nav-item.is-active { color: var(--primary-dark); background: #eceaff; }
.nav-count { min-width: 20px; padding: 2px 6px; border-radius: 8px; color: #7b8295; background: rgba(255,255,255,.75); font-size: 9px; text-align: center; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.connection-state { color: var(--muted); font-size: 10px; white-space: nowrap; }
.logout-button { min-height: 38px; padding: 8px 13px; font-size: 11px; }
.top-add { min-height: 40px; padding: 9px 15px; font-size: 12px; }

/* Library */
.main-content { min-width: 0; }
.library-section { max-width: 1440px; margin: 0 auto; padding: 42px 24px 90px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.section-heading h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.05em; }
.section-heading p { margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.heading-add { display: none; }
.toolbar { margin-top: 26px; display: grid; grid-template-columns: minmax(280px, 1fr) auto auto; gap: 10px; }
.search-field, .select-field { min-height: 46px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.9); box-shadow: 0 4px 14px rgba(49,64,104,.03); }
.search-field { gap: 10px; padding: 0 14px; }
.search-field > span { color: var(--primary); font-size: 20px; transform: rotate(-15deg); }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-field input::placeholder { color: #a5aec0; }
.search-field:focus-within { border-color: rgba(99,91,255,.5); box-shadow: 0 0 0 4px rgba(99,91,255,.08); }
.select-field { padding-left: 13px; gap: 8px; }
.select-field > span { color: var(--muted-2); font-size: 9px; }
.select-field select { border: 0; outline: 0; padding: 0 30px 0 0; color: #465168; background: transparent; font-size: 11px; font-weight: 650; }

.idea-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.idea-card { --status-color: var(--orange); min-width: 0; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); overflow: hidden; position: relative; display: flex; flex-direction: column; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.idea-card::before { content: ""; position: absolute; z-index: 2; inset: 0 auto 0 0; width: 4px; background: var(--status-color); }
.idea-card:hover { transform: translateY(-3px); border-color: #ccd4e6; box-shadow: 0 24px 65px rgba(50,68,112,.15); }
.idea-card[data-status="灵感"] { --status-color: #8b7cf6; }
.idea-card[data-status="待验证"] { --status-color: #ff9f43; }
.idea-card[data-status="验证中"] { --status-color: #14b8a6; }
.idea-card[data-status="开发中"] { --status-color: #3b82f6; }
.idea-card[data-status="暂停"] { --status-color: #9ca3af; }
.idea-card[data-status="已完成"] { --status-color: #22c55e; }
.card-image { aspect-ratio: 16 / 7; overflow: hidden; background: #eef2f8; }
.card-image img { width: 100%; height: 100%; display: block; object-fit: cover; }
.card-content { min-height: 330px; padding: 24px 28px 25px 31px; display: flex; flex-direction: column; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--status-color); font-size: 11px; font-weight: 850; }
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 12%, transparent); }
.edit-card { border: 0; padding: 7px 9px; color: var(--muted); background: transparent; font-size: 11px; }
.edit-card:hover { color: var(--primary); }
.idea-card h3 { margin: 22px 0 11px; font-size: clamp(20px, 2.2vw, 28px); line-height: 1.3; letter-spacing: -.035em; }
.card-summary { margin: 0; color: #5f697d; font-size: 13px; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.gameplay-preview { margin: 21px 0 0; padding: 17px 0 0; border-top: 1px solid #edf0f6; display: grid; gap: 9px; }
.gameplay-preview p { margin: 0; color: #647087; font-size: 11px; line-height: 1.55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gameplay-preview p::before { content: "↳"; margin-right: 8px; color: var(--status-color); font-weight: 900; }
.card-bottom { margin-top: auto; padding-top: 23px; display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 5px 9px; border: 1px solid #e2e6ef; border-radius: 8px; color: #667086; background: #f8f9fc; font-size: 9px; }
.updated-at { flex: 0 0 auto; color: var(--muted-2); font-size: 9px; }
.empty-state { margin-top: 16px; padding: 72px 24px; border: 1px dashed #cbd3e3; border-radius: 20px; text-align: center; background: rgba(255,255,255,.65); }
.empty-symbol { color: var(--primary); font-size: 36px; }
.empty-state h3 { margin: 14px 0 8px; }
.empty-state p { margin: 0 0 22px; color: var(--muted); font-size: 12px; }

/* Dialog and form */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(25,32,52,.42); backdrop-filter: blur(7px); }
.idea-dialog { width: min(920px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 34px 100px rgba(36,46,80,.26); }
.idea-dialog form { max-height: calc(100vh - 30px); display: flex; flex-direction: column; }
.dialog-header, .dialog-footer { padding: 20px 25px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.dialog-header { border-bottom: 1px solid var(--line); background: #fbfcff; }
.dialog-header .eyebrow { margin-bottom: 5px; }
.dialog-header h2 { margin: 0; font-size: 24px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: #fff; font-size: 22px; }
.dialog-body { overflow-y: auto; padding: 24px 25px 30px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.field { display: grid; gap: 8px; align-content: start; }
.field-wide { grid-column: 1 / -1; }
.field > span { color: #505a70; font-size: 11px; font-weight: 750; }
.field > span > small { margin-left: 7px; color: var(--muted-2); font-size: 9px; font-weight: 500; }
.field b { color: var(--primary); }
.field > small { color: var(--muted-2); font-size: 9px; }
.field input, .field select, .field textarea { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; outline: 0; color: var(--text); background: #fafbfe; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(99,91,255,.55); box-shadow: 0 0 0 4px rgba(99,91,255,.08); background: #fff; }
.field input::placeholder, .field textarea::placeholder { color: #abb3c3; }
.image-upload-field { position: relative; }
.image-picker { min-height: 170px; border: 1px dashed #bdc6da; border-radius: 14px; overflow: hidden; background: linear-gradient(135deg, #f3f2ff, #f6fbff); display: grid; place-items: center; cursor: pointer; position: relative; }
.image-picker:hover { border-color: var(--primary); }
.image-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.image-picker img { width: 100%; max-height: 330px; display: block; object-fit: cover; }
.image-placeholder { padding: 32px 18px; text-align: center; }
.image-placeholder b, .image-placeholder small { display: block; }
.image-placeholder b { color: var(--primary); font-size: 13px; }
.image-placeholder small { margin-top: 8px; color: var(--muted); font-size: 10px; }
.remove-image-button { justify-self: start; padding: 4px 0; border: 0; color: var(--danger); background: transparent; font-size: 10px; }
.dialog-footer { border-top: 1px solid var(--line); background: #fbfcff; }
.dialog-actions { margin-left: auto; display: flex; gap: 9px; }
.confirm-dialog { width: min(420px, calc(100vw - 30px)); padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: #fff; text-align: center; box-shadow: 0 28px 80px rgba(36,46,80,.24); }
.confirm-icon { width: 45px; height: 45px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--danger); background: #fff0f3; font-weight: 900; }
.confirm-dialog h2 { margin: 17px 0 8px; font-size: 21px; }
.confirm-dialog p { margin: 0 0 24px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.confirm-dialog > div:last-child { display: flex; justify-content: center; gap: 9px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(370px, calc(100vw - 48px)); padding: 13px 16px; border: 1px solid rgba(19,184,166,.23); border-radius: 12px; background: #eafbf8; color: #14796f; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(14px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { border-color: rgba(220,77,100,.22); color: #a33146; background: #fff0f3; }

@media (max-width: 1050px) {
    .topbar { gap: 18px; }
    .connection-state { display: none; }
    .side-nav { overflow-x: auto; }
}

@media (max-width: 760px) {
    .login-screen { display: block; }
    .login-panel { min-height: 100vh; padding: 58px 27px; border: 0; }
    .login-aside { display: none; }
    .topbar { min-height: 68px; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
    .brand span:last-child { display: none; }
    .side-nav { order: 3; width: 100%; padding-bottom: 2px; }
    .top-actions { margin-left: auto; }
    .logout-button { display: none; }
    .library-section { padding: 30px 16px 70px; }
    .section-heading { align-items: center; }
    .heading-add { display: inline-flex; }
    .top-add { display: none; }
    .toolbar { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .search-field { grid-column: 1 / -1; }
    .idea-grid { grid-template-columns: 1fr; }
    .card-content { min-height: 310px; padding: 22px 22px 23px 25px; }
    .form-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .dialog-header, .dialog-footer { padding: 18px; }
    .dialog-body { padding: 20px 18px 26px; }
    .dialog-footer { align-items: stretch; flex-direction: column-reverse; }
    .dialog-actions { width: 100%; margin: 0; }
    .dialog-actions button { flex: 1; }
}

@media (max-width: 430px) {
    .section-heading h1 { font-size: 30px; }
    .heading-add { padding-inline: 12px; font-size: 11px; }
    .toolbar { grid-template-columns: 1fr; }
    .search-field { grid-column: auto; }
    .nav-item { padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
