:root {
  --ink: #182230;
  --muted: #738095;
  --line: #e4e8ef;
  --canvas: #f4f6f9;
  --panel: #ffffff;
  --navy: #172235;
  --navy-soft: #202e44;
  --green: #62dc76;
  --green-dark: #2cb657;
  --blue: #2684ef;
  --coral: #ff7b63;
  --shadow: 0 22px 60px rgba(35, 48, 69, .14);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.topbar { height: 74px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 38px; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: .01em; }
.brand-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.autosave-state { font-size: 11px; color: var(--muted); margin-right: 8px; }
.button { border: 0; border-radius: 9px; padding: 10px 14px; font-size: 12px; font-weight: 700; transition: transform .2s, box-shadow .2s, background .2s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--navy); box-shadow: 0 7px 14px rgba(23, 34, 53, .17); }
.button.primary:hover { background: #233550; }
.button.ghost { color: var(--muted); background: #f4f6f8; }
.button.wide { width: 100%; display: flex; justify-content: center; align-items: center; gap: 5px; }
.button-icon { font-size: 15px; line-height: 0; }

.workspace { display: grid; grid-template-columns: minmax(360px, 470px) minmax(440px, 1fr); gap: 30px; max-width: 1380px; margin: 0 auto; padding: 30px 38px 46px; align-items: start; }
.editor-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(28, 40, 58, .05); overflow: hidden; }
.panel-heading { padding: 24px 24px 20px; display: flex; justify-content: space-between; align-items: start; }
.eyebrow { color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 8px; font-weight: 800; }
.panel-heading h1 { font-size: 21px; margin: 0; letter-spacing: -.02em; }
.live-dot { color: #4d9670; font-size: 10px; display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; }
.live-dot i { width: 6px; height: 6px; background: var(--green-dark); border-radius: 50%; display: block; box-shadow: 0 0 0 3px #e4f6e9; }
.editor-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 24px; gap: 22px; }
.editor-tab { border: 0; background: none; padding: 13px 1px 12px; font-size: 12px; color: var(--muted); position: relative; }
.editor-tab.active { color: var(--ink); font-weight: 800; }
.editor-tab.active::after { content: ""; height: 2px; background: var(--blue); left: 0; right: 0; bottom: -1px; position: absolute; }
.editor-section { display: none; padding: 22px 24px 26px; }
.editor-section.active { display: block; }
.section-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.section-title-row.split { margin-top: 25px; }
.section-title-row h2 { font-size: 12px; margin: 0; letter-spacing: .01em; }
.section-title-row span { font-size: 10px; color: var(--muted); }
.tip { font-size: 10px; color: #98a5b5; }
.field-label { display: block; color: #6d7887; font-size: 11px; font-weight: 700; margin-bottom: 12px; }
.field-label.compact { margin-bottom: 8px; }
.text-input, .text-area, .select-input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fbfcfd; padding: 10px 11px; margin-top: 6px; outline: none; font-size: 12px; transition: border .2s, box-shadow .2s; }
.text-input:focus, .text-area:focus, .select-input:focus { border-color: #8fbef6; box-shadow: 0 0 0 3px rgba(38,132,239,.10); }
.text-area { resize: vertical; line-height: 1.5; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.avatar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.upload-card { border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; padding: 11px; }
.upload-card-head { display: flex; justify-content: space-between; color: #6d7887; font-size: 10px; font-weight: 700; }
.upload-card-head span:last-child { color: #a2adbb; font-weight: 500; max-width: 65px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-preview { width: 46px; height: 46px; border-radius: 13px; background: #d4ead2; color: #2c7440; display: grid; place-items: center; margin: 11px auto 9px; font-size: 16px; font-weight: 800; overflow: hidden; }
.avatar-preview.them { background: #ece0d6; color: #8b5b42; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-button { border-radius: 6px; background: #eef2f7; color: #627084; font-size: 10px; display: block; text-align: center; padding: 7px 5px; cursor: pointer; }
.upload-button:hover { background: #e6ebf2; color: var(--ink); }
.upload-button input, .mini-upload input { display: none; }
.rule-preview { border-radius: 8px; background: #f5f8fb; padding: 10px 11px; display: flex; align-items: center; gap: 8px; font-size: 11px; }
.rule-label { color: #8b96a5; font-size: 10px; }
.rule-preview code { color: var(--blue); font-family: inherit; font-weight: 800; }
.rule-arrow { color: #aab5c2; }
#targetUrlPreview { color: #596777; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-list { display: flex; flex-direction: column; gap: 7px; max-height: 228px; overflow: auto; padding-right: 2px; }
.message-row { border: 1px solid #edf0f4; border-radius: 9px; padding: 8px 9px; display: flex; align-items: center; gap: 9px; background: #fcfdfe; }
.message-side-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.message-side-dot.me { background: var(--green-dark); }
.message-side-dot.them { background: #9ba9bb; }
.message-row-content { flex: 1; min-width: 0; }
.message-row-label { font-size: 9px; color: var(--muted); margin-bottom: 2px; }
.message-row-text { color: #4d5a6a; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-remove { width: 23px; height: 23px; border: 0; border-radius: 6px; background: #f2f4f6; color: #9aa4b0; font-size: 14px; }
.message-remove:hover { color: #d96050; background: #fff0ed; }
.composer-card { margin-top: 11px; border: 1px solid #dfe6ee; border-radius: 11px; padding: 10px; background: #f8fafc; }
.composer-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.select-input { margin: 0; width: auto; min-width: 104px; padding: 8px 9px; font-size: 10px; background: #fff; }
.mini-upload { background: #edf2f7; border-radius: 6px; padding: 7px 10px; color: #6b7a8d; font-size: 10px; cursor: pointer; }
.message-input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; resize: none; padding: 9px 10px; font-size: 11px; outline: none; margin-bottom: 8px; }
.message-input:focus { border-color: #8fbef6; }
.upload-wide { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #fbfcfd; border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; }
.upload-wide strong { font-size: 11px; display: block; }
.upload-wide small { display: block; color: #9ba7b6; font-size: 10px; margin-top: 4px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.resource-note { background: #fff8ed; border: 1px solid #f6e8cb; color: #8b775d; border-radius: 9px; padding: 10px; display: flex; gap: 8px; margin-top: 19px; font-size: 10px; line-height: 1.55; }
.note-icon { border-radius: 50%; width: 15px; height: 15px; background: #f2b85e; color: #fff; display: inline-grid; place-items: center; flex: 0 0 auto; font-size: 10px; font-weight: 800; }

.preview-stage { min-width: 0; display: flex; flex-direction: column; align-items: center; }
.stage-toolbar { width: min(100%, 620px); display: flex; justify-content: space-between; align-items: center; padding: 0 4px 15px; }
.stage-toolbar .eyebrow { display: inline-block; margin: 0 9px 0 0; }
.stage-toolbar strong { font-size: 13px; }
.stage-tools { display: flex; align-items: center; gap: 8px; }
.device-pill { border: 1px solid var(--line); background: #fff; color: #8290a1; border-radius: 99px; font-size: 10px; padding: 6px 10px; }
.icon-button { width: 29px; height: 29px; border-radius: 8px; border: 1px solid var(--line); color: #657487; background: #fff; }
.phone-frame { width: min(390px, 100%); padding: 11px; background: #161d29; border-radius: 36px; box-shadow: var(--shadow); position: relative; }
.phone-speaker { width: 78px; height: 5px; background: #2c3748; border-radius: 4px; position: absolute; top: 6px; left: calc(50% - 39px); z-index: 2; }
.phone-screen { border-radius: 27px; overflow: hidden; background: #f2f3f5; height: min(730px, calc(100vh - 150px)); min-height: 650px; position: relative; }
.status-bar { height: 28px; background: #f2f3f5; display: flex; justify-content: space-between; align-items: end; padding: 7px 15px 2px; color: #20242b; font-size: 10px; font-weight: 800; }
.status-icons { color: #2b3139; font-size: 9px; letter-spacing: .07em; }
.phone-view { display: none; height: calc(100% - 28px); position: relative; }
.phone-view.active { display: flex; flex-direction: column; }
.phone-nav, .resource-nav { height: 62px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: #f2f3f5; border-bottom: 1px solid #e0e2e5; flex: 0 0 auto; }
.nav-icon { border: 0; background: transparent; color: #19202a; font-size: 35px; font-weight: 300; line-height: 1; width: 36px; height: 36px; padding: 0; display: grid; place-items: center; }
.nav-icon.more { font-size: 16px; letter-spacing: 3px; }
.nav-title { text-align: center; min-width: 0; }
.nav-title strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-title span { display: block; font-size: 9px; color: #8993a1; margin-top: 3px; }
.chat-content { flex: 1; overflow: auto; padding: 15px 12px 15px; display: flex; flex-direction: column; gap: 15px; scrollbar-width: thin; }
.message { display: flex; align-items: flex-start; gap: 8px; max-width: 92%; }
.message.me { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar { width: 33px; height: 33px; flex: 0 0 auto; border-radius: 9px; background: #d5ead3; color: #2c7440; display: grid; place-items: center; font-size: 11px; font-weight: 800; overflow: hidden; }
.message-avatar.them { background: #e9ddd6; color: #8b5b42; }
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bubble { background: #fff; border-radius: 4px 12px 12px 12px; padding: 9px 11px; color: #25303d; font-size: 13px; line-height: 1.46; box-shadow: 0 1px 1px rgba(40, 50, 65, .03); word-break: break-word; }
.message.me .bubble { background: var(--green); border-radius: 12px 4px 12px 12px; color: #15311e; }
.bubble a.ip-link { color: var(--blue); text-decoration: none; border-bottom: 1px dashed rgba(38,132,239,.55); font-weight: 700; cursor: pointer; }
.message.me .bubble a.ip-link { color: #245fb2; }
.image-bubble { padding: 0; overflow: hidden; max-width: 220px; cursor: zoom-in; }
.image-bubble img { display: block; width: 220px; height: 124px; object-fit: cover; }
.compose-bar { height: 62px; border-top: 1px solid #e0e2e5; background: #f5f6f8; display: flex; align-items: center; gap: 7px; padding: 9px 11px; flex: 0 0 auto; }
.compose-icon { border: 0; background: none; width: 28px; color: #656e79; font-size: 23px; padding: 0; line-height: 1; }
.compose-icon.add { font-size: 27px; }
.compose-field { flex: 1; min-width: 0; height: 38px; background: #fff; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; color: #a2a9b2; font-size: 11px; }
.compose-field button { border: 0; background: none; color: #66717e; font-size: 18px; }

.simple-nav { height: 54px; background: #fff; display: flex; align-items: center; padding: 0 13px; }
.gate-view { background: #fff; }
.gate-content { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 72px 23px 30px; text-align: center; }
.info-symbol { width: 65px; height: 65px; border-radius: 50%; background: #28a5eb; color: #fff; display: grid; place-items: center; font-size: 39px; font-weight: 700; font-family: Georgia, serif; }
.gate-content h2 { margin: 25px 0 22px; font-size: 25px; letter-spacing: -.04em; }
.gate-url { font-size: 17px; color: #20252d; margin: 0; word-break: break-all; }
.gate-note { font-size: 12px; color: #373e48; margin: 50px 0 0; }
.gate-button { margin-top: auto; width: min(100%, 255px); height: 51px; border: 0; background: #f1f1f1; border-radius: 11px; color: #20242b; font-size: 15px; font-weight: 700; }
.gate-button:hover { background: #e4e5e7; }

.resource-view { background: #f8fafc; }
.resource-nav { background: #f1f3f6; }
.resource-content { flex: 1; overflow: auto; padding: 17px 12px 23px; }
.browser-tip { color: #e7463a; border: 1px solid #b9d9f5; border-radius: 11px; padding: 11px 8px; font-size: 14px; font-weight: 900; text-align: center; background: #f8fcff; }
.resource-intro-card { border: 1px solid #d9eaf5; border-radius: 17px; padding: 17px 16px 14px; margin-top: 13px; background: #fff; }
.intro-kicker { color: #ef4a3c; font-weight: 900; font-size: 15px; margin-bottom: 10px; }
.resource-intro-card p { margin: 0; color: #4a5868; font-size: 11px; line-height: 1.7; white-space: pre-line; }
.intro-button { margin-top: 13px; border: 0; background: #2297e8; color: #fff; border-radius: 9px; padding: 9px 17px; font-size: 11px; font-weight: 800; }
.resource-image-wrap { margin-top: 13px; border-radius: 15px; overflow: hidden; height: 150px; background: #dfe8f0; }
.resource-image-wrap img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 24%; }
.category-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 15px 3px 10px; color: #ef6256; font-size: 12px; font-weight: 800; text-align: center; }
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.game-card { border-radius: 11px; overflow: hidden; background: #fff; border: 1px solid #dfe6ef; }
.game-card img { width: 100%; height: 76px; display: block; object-fit: cover; }
.game-card span { display: block; padding: 8px 8px 9px; font-size: 10px; color: #3a4a5f; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resource-footer { display: flex; justify-content: center; gap: 6px; padding: 15px 0 0; }
.resource-footer span { width: 21px; height: 21px; border-radius: 50%; background: #d8dde4; color: #fff; display: grid; place-items: center; font-size: 9px; }
.resource-footer span:first-child { background: #2297e8; }
.preview-caption { margin-top: 14px; color: #7b8796; font-size: 10px; display: flex; gap: 6px; align-items: center; }
.preview-dot { width: 6px; height: 6px; background: var(--blue); border-radius: 50%; }

.lightbox { display: none; position: fixed; inset: 0; z-index: 30; background: rgba(15, 22, 31, .86); align-items: center; justify-content: center; padding: 30px; }
.lightbox.open { display: flex; }
.lightbox img { max-width: min(90vw, 680px); max-height: 86vh; object-fit: contain; border-radius: 8px; }
.lightbox button { position: fixed; top: 20px; right: 25px; border: 0; background: rgba(255,255,255,.15); color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 25px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 15px; border-radius: 8px; background: #1e2938; color: #fff; font-size: 11px; z-index: 40; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .topbar { padding: 0 18px; }
  .workspace { grid-template-columns: 1fr; padding: 20px 16px 38px; gap: 25px; }
  .editor-panel { order: 2; }
  .preview-stage { order: 1; }
  .stage-toolbar { width: min(100%, 390px); }
}
@media (max-width: 520px) {
  .topbar { height: 64px; }
  .brand-subtitle { display: none; }
  .top-actions .ghost, .autosave-state { display: none; }
  .workspace { padding: 15px 10px 28px; }
  .panel-heading { padding: 20px 17px 16px; }
  .editor-tabs { padding: 0 17px; }
  .editor-section { padding: 19px 17px 22px; }
  .phone-frame { border-radius: 28px; padding: 8px; }
  .phone-screen { border-radius: 22px; min-height: 670px; height: 78vh; }
}
