:root {
  --sidebar-width: 248px;
  --settings-width: 322px;
  --page-border: #e8e8e8;
  --surface-muted: #f7f7f8;
  --text: #1f1f1f;
  --secondary-text: #757575;
  --blue: #2f96f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #f5f5f5;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 17px; height: 17px; stroke-width: 1.85; }

/* Login */
.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; }
.login-intro { display: flex; flex-direction: column; justify-content: space-between; padding: 52px 9vw; background: #1f1f1f; color: #fff; }
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 1px solid currentColor; border-radius: 50%; }
.login-intro h1 { margin: 0; font-size: 50px; line-height: 1.16; font-weight: 650; }
.kicker { margin: 0 0 12px; font-size: 11px; letter-spacing: .08em; color: #8d8d8d; }
.intro-copy { max-width: 410px; margin: 0; color: #c7c7c7; line-height: 1.7; }
.login-surface { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-card { width: min(360px, 100%); display: grid; gap: 17px; }
.login-card h2 { margin: 0; font-size: 25px; }
.login-card p { margin: 8px 0 0; color: var(--secondary-text); font-size: 14px; }
.login-card label, .settings-form label, .dialog-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; }
.login-card input, .settings-form input, .dialog-form input, .settings-form textarea { min-width: 0; padding: 12px; border: 1px solid #dcdcdc; border-radius: 8px; background: #fff; outline: 0; }
.login-card input:focus, .settings-form input:focus, .dialog-form input:focus { border-color: #a0a0a0; box-shadow: 0 0 0 3px #00000009; }
.primary { border: 0; border-radius: 8px; padding: 12px 16px; background: #242424; color: #fff; font-weight: 650; }
.wide { width: 100%; }
.form-error { margin: 0; color: #b42318 !important; }

/* Reference chat workspace */
.planner-shell { min-height: 100vh; height: 100dvh; overflow: hidden; padding: 0; background: #f5f5f5; }
.reference-app-frame { position: relative; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--settings-width); min-height: 100vh; height: 100dvh; overflow: hidden; border: 1px solid var(--page-border); border-radius: 0; background: #fff; box-shadow: none; transition: grid-template-columns .24s ease; }
.planner-sidebar { grid-column: 1; display: flex; min-width: 0; min-height: 0; height: 100%; flex-direction: column; overflow: hidden; padding: 14px 14px 13px; background: #fbfbfb; border-right: 1px solid var(--page-border); }
.planner-logo { display: inline-grid; width: 38px; height: 38px; place-items: center; margin: 0 0 13px 6px; color: #161616; }
.planner-logo svg { width: 23px; height: 23px; stroke-width: 2; }
.primary-nav { display: grid; gap: 2px; }
.side-action, .history-list button, .show-all, .account { border: 0; background: transparent; color: #333; text-align: left; }
.side-action { display: flex; min-height: 37px; align-items: center; gap: 13px; border-radius: 8px; padding: 0 10px; font-size: 13px; }
.side-action svg { width: 17px; color: #262626; }
.side-action.selected { background: #eeeeef; font-weight: 600; }
.side-action:hover, .history-list button:hover, .show-all:hover { background: #f0f0f0; }
.history-section { margin-top: 20px; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.history-label { margin: 0 10px 10px; color: #777; font-size: 12px; }
.history-list { display: grid; min-height: 0; gap: 1px; overflow: auto; }
.history-list button { display: flex; min-width: 0; align-items: center; gap: 9px; border-radius: 7px; padding: 9px 10px; color: #6d6d6d; font-size: 12px; }
.history-list svg { width: 13px; min-width: 13px; color: #9d9d9d; }
.history-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.show-all { margin-top: 5px; border-radius: 7px; padding: 8px 10px; color: #555; font-size: 12px; }
.side-footer { display: grid; gap: 8px; margin-top: auto; }
.upgrade { display: flex; align-items: flex-start; gap: 10px; border: 1px solid #e4e4e4; border-radius: 9px; padding: 12px; background: #fff; }
.upgrade svg { width: 17px; min-width: 17px; margin-top: 1px; }
.upgrade span { display: grid; gap: 3px; }
.upgrade b { font-size: 13px; }
.upgrade small { color: #858585; font-size: 11px; }
.account { display: flex; width: 100%; align-items: center; gap: 9px; border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.account:hover { background: #f0f0f0; }
.account-avatar { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 50%; background: #dce7ef; color: #334a5a; font-size: 10px; font-weight: 700; }
.account svg { width: 17px; margin-left: auto; color: #6f6f6f; }

.planner-main { position: relative; display: grid; min-width: 0; min-height: 0; height: 100%; overflow: hidden; grid-template-rows: 50px minmax(0, 1fr) auto; background: #fff; }
.planner-top { display: flex; align-items: center; border-bottom: 1px solid var(--page-border); padding: 0 27px; }
.conversation-title { margin: 0; color: #191919; font-size: 14px; font-weight: 650; }
.planner-top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.context-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 6px; padding: 7px 8px; background: transparent; color: #4a4f55; font-size: 12px; font-weight: 600; }
.context-toggle:hover { background: #f1f2f3; color: #202428; }
.context-toggle svg { width: 16px; height: 16px; }
.icon-button.mobile-icon { display: none; }
.icon-button { display: inline-grid; place-items: center; border: 0; padding: 7px; background: transparent; color: #262626; }
.planner-messages, .planner-composer { min-width: 0; }
.planner-messages { display: grid; min-height: 0; align-content: start; gap: 20px; overflow: auto; padding: 36px 0; }
.welcome { padding-top: 101px; text-align: center; }
.welcome-logo { display: grid; width: 51px; height: 51px; place-items: center; margin: 0 auto 24px; border: 1px solid #dedede; border-radius: 50%; color: #1f1f1f; }
.welcome-logo svg { width: 31px; height: 31px; stroke-width: 1.8; }
.welcome h1 { margin: 0; color: #151515; font-size: 28px; font-weight: 680; line-height: 1.3; }
.planner-composer { z-index: 1; width: min(600px, calc(100% - 48px)); margin: 0 auto 13px; border: 1px solid #e2e2e2; border-radius: 17px; padding: 13px 14px 10px; background: #fff; box-shadow: 0 3px 9px #0000000a; }
.planner-composer textarea { display: block; width: 100%; min-height: 30px; max-height: 160px; resize: none; border: 0; padding: 0 0 8px; outline: 0; color: #303030; font-size: 13px; line-height: 1.5; }
.planner-composer textarea::placeholder { color: #999; }
.attachment-list { display: none; flex-wrap: wrap; gap: 6px; padding: 0 0 9px; }
.planner-composer.has-attachments .attachment-list { display: flex; }
.attachment-chip { display: inline-flex; max-width: 100%; align-items: center; gap: 5px; border: 1px solid #e0e0e0; border-radius: 6px; padding: 4px 6px 4px 8px; background: #f8f8f8; color: #4e4e4e; font-size: 11px; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { display: inline-grid; width: 16px; height: 16px; place-items: center; border: 0; border-radius: 4px; padding: 0; background: transparent; color: #717171; }
.attachment-chip button:hover { background: #e8e8e8; color: #292929; }
.attachment-chip svg { width: 12px; height: 12px; }
.attachment-notice { margin: 0 0 8px; color: #b42318; font-size: 11px; }
.compose-tools { display: flex; align-items: center; min-height: 28px; gap: 7px; }
.compose-left-tools { display: flex; gap: 2px; }
.tool-button, .voice-button { display: inline-grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 6px; background: transparent; color: #707070; }
.tool-button:hover, .voice-button:hover { background: #f1f1f1; color: #333; }
.tool-button svg, .voice-button svg { width: 16px; }
.round-send { display: inline-grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 50%; background: #efeff0; color: #707070; }
.round-send svg { width: 16px; }
.suggestions { display: none; }
.welcome-active .planner-composer { position: absolute; top: 322px; right: 0; left: 0; }
.welcome-active .suggestions { position: absolute; top: 448px; right: 0; left: 0; display: flex; justify-content: center; gap: 10px; }
.suggestions button { display: inline-flex; height: 36px; align-items: center; gap: 7px; border: 1px solid #dedede; border-radius: 9px; padding: 0 13px; background: #fff; color: #454545; font-size: 12px; }
.suggestions button:hover { background: #f8f8f8; border-color: #d2d2d2; }
.suggestions svg { width: 15px; color: #348ff2; }
.suggestions button:first-child svg { color: #e6a821; }
.message { white-space: pre-wrap; word-break: break-word; }
.message:first-child { margin-top: 0; }
.message.user { justify-self: end; width: fit-content; max-width: min(72%, 520px); margin-right: clamp(26px, 8vw, 110px); border-radius: 18px; padding: 10px 14px; background: #f1f1f1; color: #242424; font-size: 14px; font-weight: 400; line-height: 1.65; }
.message.assistant { justify-self: start; width: min(680px, calc(100% - 52px)); margin-left: clamp(26px, 8vw, 110px); padding: 3px 0; color: #1f1f1f; font-size: 15px; line-height: 1.9; }
.message.assistant.pending { display: inline-flex; width: auto; align-items: center; gap: 8px; min-height: 32px; border-radius: 8px; padding: 7px 10px; background: #f7f7f8; color: #676767; font-size: 13px; line-height: 1.5; }
.waiting-label { white-space: nowrap; }
.waiting-dots { display: inline-flex; width: 18px; color: #3d82d1; font-style: normal; letter-spacing: 2px; }
.waiting-dots::after { content: "..."; animation: plan-pulse 1.05s steps(4, end) infinite; }
.message.assistant p { margin: 0 0 18px; }
.message.assistant h3, .message.assistant h4, .message.assistant h5 { margin: 22px 0 10px; color: #171717; font-size: 16px; line-height: 1.45; }
.message.assistant h4 { font-size: 15px; }
.message.assistant h5 { font-size: 14px; }
.message.assistant ul, .message.assistant ol { margin: 0 0 18px; padding-left: 24px; }
.message.assistant li { margin: 5px 0; }
.message.assistant blockquote { margin: 0 0 18px; border-left: 3px solid #d7d7d7; padding: 3px 0 3px 14px; color: #555; }
.message.assistant hr { height: 1px; margin: 22px 0; border: 0; background: #e7e7e7; }
.message.assistant table { width: 100%; overflow: hidden; margin: 0 0 18px; border: 1px solid #e5e5e5; border-collapse: separate; border-spacing: 0; border-radius: 7px; color: #303030; font-size: 13px; }
.message.assistant th, .message.assistant td { border-bottom: 1px solid #e8e8e8; padding: 8px 10px; text-align: left; vertical-align: top; }
.message.assistant th { background: #f7f7f7; color: #242424; font-weight: 650; }
.message.assistant tr:last-child td { border-bottom: 0; }
.message.assistant code { border-radius: 4px; padding: 2px 5px; background: #f1f1f1; color: #232323; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }
.message.assistant pre { overflow: auto; margin: 0 0 18px; border-radius: 7px; padding: 13px; background: #f4f4f4; }
.message.assistant pre code { padding: 0; background: transparent; }
.message.assistant a { color: #1769aa; text-decoration: underline; }

@media (min-width: 1281px) {
  .planner-shell.config-closed .reference-app-frame { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) 0; }
  .planner-shell.config-closed .config-panel { width: 0; opacity: 0; transform: translateX(20px); border-left-color: transparent; pointer-events: none; }
}

.config-panel { grid-column: 3; width: var(--settings-width); min-width: 0; overflow: hidden; border-left: 1px solid var(--page-border); background: #fff; opacity: 1; transform: translateX(0); transition: width .24s ease, opacity .18s ease, transform .24s ease, border-color .18s ease; }
.config-panel > header { display: flex; height: 50px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--page-border); padding: 0 18px 0 24px; }
.config-panel h2 { margin: 0; font-size: 14px; }
.close-button svg { width: 17px; color: #4b4b4b; }
.config-scroll { display: grid; height: calc(100vh - 80px); align-content: start; gap: 29px; overflow: auto; padding: 25px 26px 18px; }
.config-scroll section { display: grid; gap: 10px; }
.config-scroll h3 { margin: 0; color: #282828; font-size: 12px; }
.runtime-model { display: flex; min-height: 38px; align-items: center; gap: 9px; border: 1px solid #e3e3e3; border-radius: 8px; padding: 0 11px; background: #fafafa; color: #3c3c3c; font-size: 12px; font-weight: 600; }
.runtime-model svg { width: 16px; color: #4b7da8; }
.config-drive { display: flex; min-height: 61px; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #ebebeb; border-radius: 8px; padding: 11px 12px; background: #fafafa; }
.config-drive div { display: grid; gap: 3px; }
.config-drive b { font-size: 12px; }
.config-drive span { color: #444; font-size: 11px; }
.config-drive small { color: #858585; font-size: 10px; }
.config-drive em { border: 1px solid #e2e2e2; border-radius: 6px; padding: 5px 9px; background: #fff; color: #333; font-size: 11px; font-style: normal; font-weight: 600; }

.dialog-form { min-width: 320px; padding: 20px; }
.dialog-form header { display: flex; align-items: center; justify-content: space-between; }
.dialog-form h2 { margin: 0; font-size: 16px; }
.dialog-form { display: grid; gap: 16px; border: 0; }
.dialog-form input { width: 100%; }
.text-button { border: 0; background: transparent; color: #6a6a6a; font-size: 13px; }
dialog { border: 0; border-radius: 12px; box-shadow: 0 18px 60px #0003; }
dialog::backdrop { background: #0004; }

/* Chat context history */
.context-dialog { width: min(1080px, calc(100vw - 32px)); max-width: none; max-height: min(760px, calc(100vh - 48px)); padding: 0; background: #fff; }
.context-dialog-shell { display: grid; min-height: min(600px, calc(100vh - 48px)); grid-template-rows: auto minmax(0, 1fr); }
.context-dialog-shell > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid #e4e6e8; padding: 20px 22px 16px; }
.context-dialog-shell h2 { margin: 0; color: #202326; font-size: 18px; }
.context-dialog-shell > header p { margin: 6px 0 0; color: #737980; font-size: 12px; line-height: 1.5; }
.context-trace-layout { display: grid; min-height: 0; grid-template-columns: minmax(205px, 250px) minmax(0, 1fr); }
.context-trace-sidebar { min-height: 0; overflow: auto; border-right: 1px solid #e4e6e8; padding: 14px; background: #fafbfc; }
.context-trace-label { margin: 0 0 9px; padding: 0 5px; color: #727980; font-size: 12px; font-weight: 650; }
.context-trace-list { display: grid; gap: 5px; }
.context-trace-item { display: grid; width: 100%; gap: 4px; border: 1px solid transparent; border-radius: 7px; padding: 10px; background: transparent; color: #3e444b; text-align: left; }
.context-trace-item:hover { background: #f0f2f4; }
.context-trace-item.selected { border-color: #d5dce4; background: #eaf0f5; color: #23384a; }
.context-trace-item strong { font-size: 13px; }
.context-trace-item span, .context-trace-item time { color: #737a81; font-size: 11px; line-height: 1.35; }
.context-trace-detail { min-height: 0; overflow: auto; padding: 18px 20px 24px; background: #fff; }
.context-detail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.context-detail-heading h3 { margin: 0; color: #25292d; font-size: 15px; }
.context-detail-heading p { margin: 0; color: #7b8289; font-size: 12px; }
.context-detail-empty { min-height: 220px; place-content: center; }
.context-empty { display: grid; margin: 0; border: 1px dashed #d9dfe5; border-radius: 7px; padding: 18px; color: #78808a; font-size: 12px; line-height: 1.55; text-align: center; }
.context-step { display: grid; gap: 8px; border-top: 1px solid #e8eaed; padding: 17px 0; }
.context-step:first-of-type { border-top: 0; padding-top: 0; }
.context-step > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.context-step h4 { margin: 0; color: #2a2f34; font-size: 14px; }
.context-step > header span { overflow-wrap: anywhere; color: #78808a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-align: right; }
.context-fold { border: 1px solid #e0e4e8; border-radius: 7px; background: #fbfcfd; }
.context-fold > summary { cursor: pointer; padding: 10px 11px; color: #3d454d; font-size: 12px; font-weight: 650; }
.context-fold > summary::marker { color: #7b8793; }
.context-fold > pre, .context-message pre { max-height: 310px; overflow: auto; margin: 0; border-top: 1px solid #e5e8eb; padding: 11px; background: #fff; color: #30363b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.context-message-list, .context-tool-list { display: grid; gap: 8px; border-top: 1px solid #e5e8eb; padding: 10px; }
.context-message, .context-tool { display: grid; gap: 7px; border: 1px solid #e2e6e9; border-radius: 6px; overflow: hidden; background: #fff; }
.context-message strong, .context-tool > strong { padding: 8px 10px 0; color: #555e67; font-size: 11px; }
.context-tool > .context-fold { margin: 0 9px 9px; }
.context-tool > .context-fold > pre { max-height: 220px; }
.context-message-list .context-empty, .context-tool-list .context-empty { border: 0; padding: 6px; background: transparent; }

/* Personal settings */
.settings-page .planner-main { grid-template-rows: 50px minmax(0, 1fr); }
.settings-header { justify-content: space-between; }
.settings-workspace { min-width: 0; overflow: auto; background: #f7f8fa; }
.settings-content { display: grid; width: min(920px, 100%); gap: 22px; padding: 38px clamp(20px, 5vw, 58px) 54px; }
.settings-section { display: grid; gap: 18px; border-bottom: 1px solid #e2e4e8; padding-bottom: 30px; }
.settings-section h2 { margin: 0; color: #222; font-size: 21px; }
.settings-section p { margin: 8px 0 0; color: var(--secondary-text); font-size: 14px; line-height: 1.7; }
.model-settings-section { gap: 14px; }
.model-picker { display: grid; width: min(480px, 100%); gap: 7px; color: #535861; font-size: 13px; font-weight: 650; }
.model-picker select { width: 100%; min-height: 42px; border: 1px solid #d5d9df; border-radius: 8px; padding: 0 12px; background: #fff; color: #24272d; font-size: 14px; outline: 0; }
.model-picker select:focus { border-color: #6b8bb9; box-shadow: 0 0 0 3px #497ab315; }
.model-picker select:disabled { cursor: wait; background: #f4f5f6; color: #737980; }
.settings-runtime { justify-self: start; margin: 0 !important; border: 1px solid #dbe1e9; border-radius: 8px; padding: 9px 12px; background: #f4f7fb; color: #304b70 !important; font-size: 13px !important; font-weight: 650; }
.model-status { min-height: 20px; margin: -5px 0 0 !important; font-size: 13px !important; }
.model-status.pending { color: #3975d6; }
.model-status.success { color: #22734b; }
.model-status.error { color: #b42318; }
.inline { justify-self: start; }
.upgrade.selected { border-color: #cfd5dc; background: #f0f1f3; }

/* Life system and personal context */
.life-system-page .planner-main, .profile-page .planner-main { min-width: 0; grid-template-rows: 50px minmax(0, 1fr); }
.workspace-header { justify-content: space-between; }
.life-workspace { min-width: 0; min-height: 0; overflow: auto; background: #f7f8fa; }
.life-content { display: grid; width: min(1120px, 100%); gap: 30px; padding: 32px clamp(20px, 4vw, 48px) 52px; }
.workspace-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; border-bottom: 1px solid #dfe2e6; padding-bottom: 22px; }
.workspace-intro h2 { margin: 0; color: #222; font-size: 24px; }
.workspace-intro > p { max-width: 430px; margin: 0; color: #6f747b; font-size: 13px; line-height: 1.65; text-align: right; }
.direction-form, .goal-section, .proposal-section, .recent-section { display: grid; gap: 16px; }
.direction-form { grid-template-columns: 1fr 1fr; border-bottom: 1px solid #dfe2e6; padding-bottom: 30px; }
.section-heading { display: flex; grid-column: 1 / -1; align-items: flex-start; justify-content: space-between; gap: 18px; }
.section-heading h3 { margin: 0; color: #252525; font-size: 18px; }
.section-heading p { margin: 5px 0 0; color: #777d84; font-size: 13px; line-height: 1.55; }
.version-label { border-radius: 5px; padding: 4px 7px; background: #e9eef4; color: #455c74; font-size: 11px; }
.direction-form label, .goal-card label, .edit-dialog label { display: grid; gap: 6px; color: #50565e; font-size: 12px; font-weight: 650; }
.direction-form input, .direction-form textarea, .goal-card input, .goal-card textarea, .goal-card select, .edit-dialog input, .edit-dialog textarea { width: 100%; min-width: 0; border: 1px solid #d8dce1; border-radius: 7px; padding: 9px 10px; background: #fff; color: #25282c; outline: 0; }
.direction-form textarea, .goal-card textarea, .edit-dialog textarea { resize: vertical; line-height: 1.55; }
.direction-form input:focus, .direction-form textarea:focus, .goal-card input:focus, .goal-card textarea:focus, .goal-card select:focus, .edit-dialog input:focus, .edit-dialog textarea:focus { border-color: #7c91a8; box-shadow: 0 0 0 3px #52769f14; }
.form-actions { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; gap: 16px; }
.inline-feedback { min-height: 18px; margin: 0; color: #68717b; font-size: 12px; }
.inline-feedback.pending { color: #3975d6; }
.inline-feedback.success { color: #22734b; }
.inline-feedback.error { color: #b42318; }
.goal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.goal-card { display: grid; min-width: 0; gap: 12px; border: 1px solid #dfe3e8; border-radius: 8px; padding: 16px; background: #fff; }
.goal-card > header, .profile-item > header { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 10px; }
.goal-card > header div, .profile-item > header div { display: grid; min-width: 0; gap: 4px; }
.goal-card > header strong, .profile-item > header strong { overflow-wrap: anywhere; color: #222; font-size: 15px; }
.goal-horizon { color: #77808a; font-size: 11px; font-weight: 650; }
.status-badge { flex: 0 0 auto; border-radius: 5px; padding: 4px 6px; background: #edf0f3; color: #59616a; font-size: 11px; font-style: normal; }
.status-in_progress { background: #e8f1fb; color: #2d669e; }
.status-blocked { background: #fff0e2; color: #9a5b1e; }
.status-completed { background: #e6f4ea; color: #287044; }
.goal-control-row { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(0, 1.3fr); gap: 10px; }
.progress-field { position: relative; grid-template-columns: 1fr auto !important; align-items: center; }
.progress-field > input { grid-column: 1; height: 25px; padding: 0; accent-color: #4277a8; }
.progress-value { grid-column: 2; grid-row: 2; min-width: 34px; color: #3e5f7c; font-size: 12px; text-align: right; }
.goal-actions, .profile-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.proposal-list, .recent-goals, .profile-items { display: grid; gap: 9px; }
.proposal-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid #dfe3e8; border-radius: 8px; padding: 14px 16px; background: #fff; }
.proposal-item div { display: grid; gap: 5px; }
.proposal-item strong { color: #252525; font-size: 14px; }
.proposal-item p { margin: 0; color: #6e747b; font-size: 13px; }
.recent-goals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.recent-goal { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; border: 1px solid #dfe3e8; border-radius: 8px; padding: 13px 15px; background: #fff; color: #2c2c2c; text-align: left; }
.recent-goal strong { overflow-wrap: anywhere; font-size: 14px; }
.recent-goal span { color: #5f6973; font-size: 12px; }
.recent-goal p { grid-column: 1 / -1; margin: 0; color: #747b82; font-size: 12px; line-height: 1.55; }
.empty-state { margin: 0; border: 1px dashed #d3d8de; border-radius: 8px; padding: 25px; color: #7a8188; text-align: center; font-size: 13px; }
.history-dialog, .edit-dialog { display: grid; width: min(620px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); gap: 16px; overflow: auto; padding: 20px; }
.history-dialog > header, .edit-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.history-dialog h2, .edit-dialog h2 { margin: 0; font-size: 17px; }
#goal-history-list, #profile-versions { display: grid; gap: 10px; }
.history-event { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; border-bottom: 1px solid #e4e6e9; padding: 4px 0 13px; }
.history-event strong { font-size: 13px; }
.history-event time, .history-event small { color: #7b8289; font-size: 11px; }
.history-event p { grid-column: 1 / -1; margin: 0; color: #4e555d; font-size: 13px; line-height: 1.55; }

.segment-control { display: flex; width: fit-content; max-width: 100%; gap: 3px; overflow-x: auto; border: 1px solid #d9dde2; border-radius: 8px; padding: 3px; background: #fff; }
.segment-control button { min-height: 34px; border: 0; border-radius: 5px; padding: 0 13px; background: transparent; color: #626971; font-size: 12px; white-space: nowrap; }
.segment-control button.selected { background: #2d3339; color: #fff; }
.sub-tabs { display: flex; gap: 18px; border-bottom: 1px solid #dfe2e6; }
.sub-tabs button { border: 0; border-bottom: 2px solid transparent; padding: 8px 2px 10px; background: transparent; color: #747a81; font-size: 13px; }
.sub-tabs button.selected { border-bottom-color: #2f353b; color: #25292d; font-weight: 650; }
.profile-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.toggle-field { display: inline-flex; align-items: center; gap: 7px; color: #636a72; font-size: 12px; }
.toggle-field input { width: 15px; height: 15px; accent-color: #333a42; }
.profile-item { display: grid; gap: 10px; border: 1px solid #dfe3e8; border-radius: 8px; padding: 15px 16px; background: #fff; }
.profile-item.inactive { background: #f4f5f6; opacity: .78; }
.profile-item > header span { color: #7b8289; font-size: 11px; }
.profile-statement { margin: 0; color: #34393f; font-size: 14px; line-height: 1.65; }
.profile-applicability { margin: 0; color: #6c747c; font-size: 12px; }

@media (max-width: 980px) {
  .goal-grid { grid-template-columns: 1fr; }
  .goal-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .goal-card > header, .goal-card > .inline-feedback, .goal-card > .goal-actions { grid-column: 1 / -1; }
}

/* Daily plan workspace */
.daily-plan-page { min-width: 0; padding: 0; overflow-x: clip; }
.daily-plan-page { font-size: 16px; }
.daily-plan-page .reference-app-frame { min-height: 100vh; border-radius: 0; }
.daily-plan-page .reference-app-frame { box-shadow: none; }
.daily-plan-page .planner-main { grid-template-rows: 50px minmax(0, 1fr); }
.daily-plan-page .conversation-title { font-size: 16px; }
.daily-plan-header { justify-content: space-between; }
.daily-plan-workspace { min-width: 0; min-height: 0; overflow: auto; container-name: daily-plan-main; container-type: inline-size; background: #f7f8fa; }
.daily-plan-tabs { display: flex; gap: 3px; border-bottom: 1px solid #e5e7eb; padding: 13px 24px 0; background: #fff; }
.daily-plan-tab { border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; background: transparent; color: #777; font-size: 15px; font-weight: 600; }
.daily-plan-tab.selected { border-bottom-color: #262626; color: #1f1f1f; }
.daily-plan-current, .plan-history { min-width: 0; padding: 22px clamp(16px, 3vw, 34px) 32px; }
.daily-plan-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.daily-plan-meta { display: flex; min-width: 0; align-items: center; gap: 18px; }
.daily-date-label { display: grid; flex: 0 0 auto; gap: 6px; color: #696969; font-size: 13px; font-weight: 650; }
.daily-date-label input { min-width: 145px; border: 1px solid #dedede; border-radius: 7px; padding: 8px 9px; background: #fff; color: #262626; font-size: 15px; }
.daily-plan-toolbar strong { color: #222; font-size: 17px; }
.daily-plan-toolbar strong.is-pending { display: inline-flex; align-items: center; gap: 7px; color: #3975d6; }
.daily-plan-toolbar strong.is-pending::after { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; animation: plan-pulse 1.05s ease-in-out infinite; }
.daily-plan-toolbar p { margin: 5px 0 0; color: #777; font-size: 14px; line-height: 1.5; }
.plan-generated-at { color: #8b8b8b !important; font-size: 13px !important; }
.daily-plan-action-area { display: grid; flex: 0 0 auto; justify-items: end; gap: 7px; }
.daily-plan-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.daily-plan-actions button, .daily-plan-actions a { display: inline-flex; min-height: 40px; align-items: center; gap: 7px; text-decoration: none; white-space: nowrap; }
.daily-plan-actions svg { width: 15px; height: 15px; }
.secondary-action { border: 1px solid #d8d8d8; border-radius: 8px; padding: 8px 12px; background: #fff; color: #333; font-size: 14px; font-weight: 650; }
.secondary-action:hover:not(:disabled) { border-color: #999; background: #fafafa; }
.daily-plan-actions button:disabled, .plan-message-form button:disabled { cursor: not-allowed; opacity: .48; }
.daily-plan-actions .is-pending { background: #929292; }
.plan-feedback { max-width: 360px; margin: 0; color: #6f6f6f; font-size: 13px; line-height: 1.45; text-align: right; }
.plan-feedback.pending { color: #3975d6; }
.plan-feedback.success { color: #2b7a50; }
.plan-feedback.error { color: #b42318; }
.daily-plan-layout { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) minmax(260px, 330px); gap: 18px; align-items: start; }
.daily-plan-preview-shell { position: relative; min-width: 0; overflow-x: clip; border: 1px solid #e0e3e8; border-radius: 9px; background: #fff; box-shadow: 0 8px 22px #18375a0a; }
.daily-plan-preview-shell iframe { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 860px; border: 0; background: #fff; }
.daily-plan-empty { display: grid; min-height: 520px; place-content: center; gap: 12px; color: #7b8492; text-align: center; }
.daily-plan-empty svg { width: 34px; height: 34px; margin: 0 auto; color: #5d7d9b; }
.daily-plan-empty p { margin: 0; font-size: 15px; }
.plan-dialogue { display: grid; min-width: 0; gap: 14px; border: 1px solid #e0e3e8; border-radius: 9px; padding: 16px; background: #fff; }
.plan-dialogue header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.plan-dialogue h2, .plan-history h2 { margin: 0; color: #272727; font-size: 18px; }
.plan-dialogue header p, .plan-history-header p { margin: 5px 0 0; color: #7b7b7b; font-size: 14px; line-height: 1.55; }
.plan-version { flex: 0 0 auto; border-radius: 5px; padding: 4px 6px; background: #f2f2f2; color: #646464; font-size: 12px; }
.plan-messages { display: grid; max-height: 390px; gap: 10px; overflow: auto; }
.plan-message { display: grid; gap: 5px; max-width: 100%; border-radius: 8px; padding: 10px; }
.plan-message.user { justify-self: end; background: #f1f1f1; color: #2b2b2b; }
.plan-message.assistant { background: #fafafa; color: #3c3c3c; }
.plan-message.pending { position: relative; padding-right: 37px; background: #f4f8ff; color: #4a6688; }
.plan-message.pending .waiting-dots { position: absolute; right: 10px; bottom: 11px; }
.plan-message span { color: #828282; font-size: 12px; font-weight: 650; }
.plan-message p { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.65; }
.plan-message-form { display: flex; align-items: flex-end; gap: 8px; border-top: 1px solid #eeeeee; padding-top: 12px; }
.plan-message-form textarea { width: 100%; min-height: 68px; resize: vertical; border: 1px solid #dedede; border-radius: 8px; padding: 9px; outline: 0; color: #333; font-size: 14px; line-height: 1.55; }
.plan-message-form textarea:focus { border-color: #a6a6a6; }
.plan-message-form textarea:disabled { background: #f7f7f7; color: #999; }
.plan-history { max-width: 980px; margin: 0 auto; }
.plan-history-header { margin-bottom: 18px; }
.plan-history-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 15px; border: 1px solid #e3e5e8; border-radius: 9px; padding: 13px; background: #fff; }
.plan-history-filters label { display: grid; gap: 5px; color: #727272; font-size: 13px; font-weight: 650; }
.plan-history-filters select, .plan-history-filters input { min-width: 132px; border: 1px solid #dedede; border-radius: 6px; padding: 7px 8px; background: #fff; color: #333; font-size: 14px; }
.plan-history-list { display: grid; gap: 8px; }
.plan-history-item { display: grid; width: 100%; grid-template-columns: 104px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; border: 1px solid #e3e5e8; border-radius: 8px; padding: 12px; background: #fff; color: #353535; text-align: left; }
.plan-history-item:hover { border-color: #bfc3c8; background: #fcfcfc; }
.plan-history-item strong { font-size: 15px; }
.plan-history-item > span { overflow: hidden; color: #656565; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.plan-history-item em { border-radius: 5px; padding: 4px 6px; background: #f2f2f2; color: #666; font-size: 12px; font-style: normal; white-space: nowrap; }
.plan-history-item small { color: #8b8b8b; font-size: 12px; white-space: nowrap; }
.plan-history-empty { margin: 0; border: 1px dashed #d7dadd; border-radius: 8px; padding: 36px; color: #8a8a8a; text-align: center; font-size: 13px; }
.plan-history-pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.plan-history-pagination button { border: 1px solid #dedede; border-radius: 6px; padding: 6px 10px; background: #fff; color: #454545; font-size: 12px; }
.plan-history-pagination button:disabled { cursor: not-allowed; opacity: .45; }
.plan-history-pagination span { color: #727272; font-size: 12px; }

@container daily-plan-main (max-width: 760px) {
  .daily-plan-toolbar, .daily-plan-meta { align-items: flex-start; flex-direction: column; }
  .daily-plan-toolbar { gap: 12px; }
  .daily-plan-action-area { width: 100%; justify-items: start; }
  .daily-plan-actions { width: 100%; justify-content: flex-start; }
  .plan-feedback { max-width: 100%; text-align: left; }
}

@keyframes plan-pulse {
  0%, 100% { opacity: .28; transform: translateY(1px); }
  50% { opacity: 1; transform: translateY(-1px); }
}

@media (max-width: 1280px) {
  .reference-app-frame { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .config-panel { position: fixed; z-index: 5; top: 0; right: 0; bottom: 0; width: min(var(--settings-width), 92vw); opacity: 0; transform: translateX(100%); pointer-events: none; box-shadow: -10px 0 30px #00000010; }
  .config-scroll { height: calc(100vh - 50px); }
  .planner-shell.config-open .config-panel { opacity: 1; transform: translateX(0); pointer-events: auto; }
  .planner-shell.config-open::after { position: fixed; z-index: 4; inset: 0; background: #0000002e; content: ""; }
}

@media (max-width: 1040px) {
  .daily-plan-layout { grid-template-columns: 1fr; }
  .plan-dialogue { grid-row: 1; }
}

@media (max-width: 700px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: 35vh; padding: 30px; }
  .login-intro h1 { font-size: 33px; }
  .intro-copy { display: none; }
  .planner-shell { min-height: 100vh; height: auto; overflow: visible; padding: 0; }
  .reference-app-frame { display: block; min-height: 100vh; height: auto; border: 0; border-radius: 0; box-shadow: none; }
  .planner-sidebar { position: fixed; z-index: 6; inset: 0 auto 0 0; width: min(84vw, 318px); transform: translateX(-100%); transition: transform .2s ease; box-shadow: 9px 0 25px #00000016; }
  .planner-shell.menu-open .planner-sidebar { transform: translateX(0); }
  .planner-shell.menu-open::after { position: fixed; z-index: 5; inset: 0; background: #0000002e; content: ""; }
  .planner-main { min-height: 100vh; grid-template-rows: 54px minmax(0, 1fr) auto; }
  .planner-top { justify-content: space-between; padding: 0 12px; }
  .icon-button.mobile-icon { display: inline-grid; }
  .conversation-title { font-size: 14px; }
  .context-toggle { width: 34px; height: 34px; justify-content: center; padding: 0; }
  .context-toggle span { display: none; }
  .welcome { padding-top: 72px; }
  .welcome-logo { width: 46px; height: 46px; margin-bottom: 20px; }
  .welcome-logo svg { width: 27px; height: 27px; }
  .welcome h1 { font-size: 22px; }
  .planner-composer { width: calc(100% - 32px); margin-bottom: 10px; border-radius: 17px; }
  .welcome-active .planner-composer { top: 267px; }
  .welcome-active .suggestions { top: 388px; display: grid; width: 292px; margin: 0 auto; grid-template-columns: 1fr 1fr; gap: 10px; }
  .suggestions button { justify-content: center; min-width: 0; padding: 0 8px; font-size: 11px; white-space: nowrap; }
  .planner-messages { gap: 16px; padding: 24px 0; }
  .message.user { max-width: calc(100% - 32px); margin-right: 16px; }
  .message.assistant { width: calc(100% - 32px); margin-left: 16px; }
  .config-panel { z-index: 7; width: 100%; }
  .config-panel > header { height: 54px; padding: 0 16px; }
  .config-scroll { height: calc(100vh - 54px); padding: 25px 20px 18px; }
  .settings-content { padding: 24px 18px 36px; }
  .daily-plan-page .planner-main { min-height: 100vh; grid-template-rows: 54px minmax(0, 1fr); }
  .daily-plan-tabs { padding: 11px 16px 0; }
  .daily-plan-current, .plan-history { padding: 16px; }
  .daily-plan-toolbar, .daily-plan-meta { align-items: flex-start; flex-direction: column; }
  .daily-plan-toolbar { gap: 12px; }
  .daily-plan-actions { width: 100%; justify-content: flex-start; }
  .daily-plan-action-area { width: 100%; justify-items: start; }
  .plan-feedback { max-width: 100%; text-align: left; }
  .daily-date-label { width: 100%; }
  .daily-date-label input { width: 100%; }
  .daily-plan-layout { gap: 14px; }
  .daily-plan-preview-shell { min-height: 0; border-right: 0; border-left: 0; border-radius: 0; }
  .daily-plan-preview-shell iframe { min-height: 0; }
  .daily-plan-empty { min-height: 320px; }
  .plan-history-filters { align-items: stretch; flex-direction: column; }
  .plan-history-filters label, .plan-history-filters select, .plan-history-filters input { width: 100%; }
  .plan-history-item { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .plan-history-item > span { grid-column: 1 / -1; }
  .plan-history-item small { grid-column: 1; }
  .settings-page .planner-main { min-height: 100vh; grid-template-rows: 54px minmax(0, 1fr); }
  .settings-section h2 { font-size: 19px; }
  .life-system-page .planner-main, .profile-page .planner-main { min-height: 100vh; grid-template-rows: 54px minmax(0, 1fr); }
  .life-content { gap: 24px; padding: 22px 16px 36px; }
  .workspace-intro { align-items: flex-start; flex-direction: column; gap: 8px; }
  .workspace-intro > p { max-width: none; text-align: left; }
  .direction-form { grid-template-columns: 1fr; }
  .goal-card { grid-template-columns: 1fr; padding: 14px; }
  .goal-control-row { grid-template-columns: 1fr; }
  .proposal-item { align-items: stretch; flex-direction: column; }
  .proposal-item .primary { width: 100%; }
  .recent-goals { grid-template-columns: 1fr; }
  .segment-control { width: 100%; }
  .segment-control button { flex: 1 0 auto; }
  .profile-toolbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .context-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .context-dialog-shell { min-height: calc(100vh - 20px); }
  .context-dialog-shell > header { padding: 16px; }
  .context-trace-layout { grid-template-columns: 1fr; }
  .context-trace-sidebar { max-height: 210px; border-right: 0; border-bottom: 1px solid #e4e6e8; }
  .context-trace-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .context-trace-detail { padding: 15px; }
  .context-step > header { align-items: flex-start; flex-direction: column; gap: 4px; }
  .context-step > header span { text-align: left; }
}

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