/* Quiet backgrounds sit behind the document, never above text or controls. */
:root { --bg: #f7f8fa; --surface: #fff; --surface-alt: #eff1f5; --line: #d5d9e0; }
html[data-theme="dark"] { --bg: #080a0d; --surface: #12161b; --surface-alt: #1a2027; --line: #303842; }
body:has(.ambient-sky) { isolation: isolate; }
.ambient-sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: var(--bg); }
.ambient-sky::before, .ambient-sky::after { content: ''; position: absolute; inset: -5%; pointer-events: none; }
.ambient-sky::before {
  background: radial-gradient(ellipse at 88% 10%,#d4e3f3 0%,#e6edf5 25%,transparent 62%),
    radial-gradient(ellipse at 4% 92%,#e6dfd0 0%,#f3eee4 28%,transparent 70%);
  opacity: .82;
}
.ambient-sky::after { background: repeating-radial-gradient(ellipse at 105% -30%,transparent 0 92px,#6d8eb520 93px,transparent 94px 168px); opacity: .72; }
html[data-theme="dark"] .ambient-sky::before {
  background: url('/mascot/galaxy.webp') center / cover no-repeat;
  filter: grayscale(.7); opacity: .46;
  animation: sky-drift 90s linear -45s infinite alternate;
  will-change: transform;
}
html[data-theme="dark"] .ambient-sky::after {
  background: radial-gradient(ellipse at 55% 25%,transparent 0%,#080a0d1a 48%,#080a0da8 100%); opacity: 1;
}
html[data-theme="dark"] body[data-surface="selectstar"] .ambient-sky::before { opacity: .34; }
html[data-theme="dark"] body[data-typography="resume"] .ambient-sky::before { opacity: .48; }
html[data-theme="light"] body[data-typography="resume"] .ambient-sky::before {
  background: radial-gradient(ellipse at 100% 0%,#d9e5f3 0%,#e8eff7 25%,transparent 62%),
    radial-gradient(ellipse at 0% 100%,#e8dfd0 0%,#f6f0e5 30%,transparent 68%);
}
html[data-theme="light"] body[data-typography="resume"] .ambient-sky::after {
  background: repeating-radial-gradient(ellipse at 110% -20%,transparent 0 68px,#6f829d20 69px,transparent 70px 132px); opacity: .7;
}
@keyframes sky-drift { from { transform: translate3d(-8px,5px,0) scale(1.035); } to { transform: translate3d(8px,-5px,0) scale(1.035); } }
.ui-icon { display: inline-block; width: 18px; height: 18px; flex: 0 0 18px; vertical-align: middle; }
html[data-theme="dark"] .ui-icon { filter: invert(1); }
.theme-moon, html[data-theme="light"] .theme-sun { display: none; }
html[data-theme="light"] .theme-moon { display: inline-flex; }
.theme-sun { display: inline-flex; }
.theme-toggle, .logout-button { gap: 8px; }
.site-header { padding-block: 16px; }
.site-header .header-actions, .hub-header-actions { gap: 8px; }
.site-header .text-link { padding: 10px 12px; border: 1px solid transparent; border-radius: 8px; gap: 8px; }
.site-header .text-link:hover { border-color: var(--line); background: var(--surface); }
.site-header .btn, .site-header .logout-button { border-radius: 8px; background: color-mix(in srgb,var(--surface) 80%,transparent); }
.site-header .wordmark img { width: 40px; height: 40px; }
.tool-card { background: color-mix(in srgb,var(--surface) 80%,transparent); }
/* Definite image box prevents intrinsic 380px image height escaping a grid track. */
.tool-illustration { position: relative; flex: 0 0 168px; width: 100%; height: 168px; min-height: 0; overflow: hidden; }
.tool-illustration img { display: block; position: absolute; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
.tool-copy { min-width: 0; }
.tool-copy p { overflow-wrap: anywhere; }
.home-main { grid-template-columns: minmax(0,5fr) minmax(0,7fr); }
.three-worlds .portal { column-gap: 16px; }
.three-worlds:has(.paper-portal) .portal { min-height: 140px; padding-block: 12px; }
.three-worlds:has(.paper-portal) .portal-art { height: 112px; }
.paper-portal .portal-art img { transition: opacity 180ms var(--ease), transform 180ms ease; }
@media (hover:hover) and (prefers-reduced-motion:no-preference) {
  .paper-portal:hover .portal-art img { transform: translateY(-2px) scale(1.02); }
}
@media (max-width:639px) {
  .three-worlds:has(.paper-portal) .portal { min-height: 122px; padding-block: 12px; }
  .three-worlds:has(.paper-portal) .portal-art { height: 96px; }
}
.portal-title { flex-wrap: wrap; }
/* Resume remains an independent document and shares the same theme preference. */
body[data-typography="resume"] #root > .resume-shell { background: transparent !important; padding: clamp(16px,3.3vw,48px); }
body[data-typography="resume"] .resume-topbar { flex-wrap: wrap; gap: 16px; background: var(--surface); }
.resume-face { width: 40px; height: 40px; object-fit: contain; margin-right: 12px; flex-shrink: 0; }
.resume-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.resume-header-actions .btn { gap: 8px; }
.resume-language { flex-shrink: 0; min-height: 44px; }
.resume-language:has(#ko-lang-desktop:checked) label[for="ko-lang-desktop"],
.resume-language:has(#en-lang-desktop:checked) label[for="en-lang-desktop"] { color: var(--bg); }
.resume-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; padding: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.resume-tab { min-height: 48px; display: flex; justify-content: center; align-items: center; gap: 8px; padding: 8px; color: var(--muted); border: 1px solid transparent; border-radius: 8px; background: transparent; font-size: 14px; font-weight: 500; }
.resume-tab:hover { color: var(--ink); background: var(--surface-alt); }
.resume-tab.is-active { color: var(--ink); background: var(--surface-alt); border-color: var(--line); }
body[data-typography="resume"] :is(.bg-blue-900,.bg-gray-600) { background: var(--surface-alt); }
body[data-typography="resume"] :is(.text-sky-300,.text-sky-400,.text-blue-300,.text-blue-400) { color: var(--action); }
body[data-typography="resume"] :is(.text-gray-500,.text-gray-400) { color: var(--muted); }
body[data-typography="resume"] :is(.border-gray-600,.border-gray-700) { border-color: var(--line); }
body[data-typography="resume"] .hover\:bg-gray-700:hover { background: var(--surface-alt); }
body[data-typography="resume"] :is(.bg-blue-600,.bg-blue-500,.bg-blue-700) { background: var(--action); color: var(--bg); }
body[data-typography="resume"] .resume-topbar > span { color: var(--ink); font-size: clamp(21px,2.2vw,30px); }
body[data-typography="resume"] a[title] { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
body[data-typography="resume"] a[title] > div { margin-right: 0; background: transparent; border-radius: 4px; }
body[data-typography="resume"] a[title] img { object-fit: contain; }
html[data-theme="dark"] body[data-typography="resume"] a[title="GitHub"] img { filter: invert(1); }
@media (max-width:1023px) {
  .home-main { grid-template-columns: minmax(0,1fr) minmax(0,1.2fr); }
  .tool-illustration { flex-basis: 140px; height: 140px; }
}
@media (max-width:760px) {
  .site-header { flex-wrap: wrap; gap: 12px; padding-block: 16px; }
  .site-header .header-actions, .hub-header-actions { justify-content: flex-start; flex-wrap: wrap; }
  .hub-header-actions .text-link { width: auto; min-height: 44px; }
  .site-header .wordmark img { width: 32px; height: 32px; }
  .home-main { grid-template-columns: minmax(0,1fr); }
  .tool-illustration { width: 96px; height: 120px; flex: 0 0 96px; }
  .resume-topbar > span { margin: 0; }
  .resume-header-actions { justify-content: flex-start; width: 100%; }
  .resume-header-actions .btn { padding-inline: 12px; }
  .resume-tabs { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 8px; }
  .resume-tab { font-size: 13px; }
}
@media (max-width:360px) {
  .tool-illustration { flex-basis: 72px; width: 72px; }
  .theme-toggle { padding-inline: 10px; }
  .resume-header-actions .btn { padding-inline: 8px; }
}
@media (prefers-reduced-motion:reduce) {
  .ambient-sky::before { animation: none !important; transform: none; will-change: auto; }
  body[data-typography="resume"] :is(.animate-pulse,.animate-glowPulse) { animation: none; }
}
@media print { .ambient-sky, .resume-header-actions { display: none; } }

/* Research toolbar: search, navigation, tools, then logout at the far edge. */
html[data-theme] body[data-surface="research"] .topbar {
  min-height: 88px; height: auto; padding: 16px 32px; gap: 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
html[data-theme] body[data-surface="research"] .topbar-actions {
  display: flex; align-items: center; justify-content: flex-end; flex: 1; gap: 8px; min-width: 0;
}
.workspace-quick-nav { display: flex; gap: 4px; align-items: center; }
html[data-theme] body[data-surface="research"] .topbar-actions :is(.icon-button,.secondary-button,.primary-button,.workspace-logout-button) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; min-height: 44px; border-radius: 10px; font-size: 13px; white-space: nowrap;
}
html[data-theme] body[data-surface="research"] .topbar-actions .icon-button {
  width: 44px; flex: 0 0 44px; padding: 0; background: transparent; color: var(--ink); border: 1px solid var(--line);
}
html[data-theme] body[data-surface="research"] .topbar-actions .secondary-button { background: transparent; padding: 0 12px; }
html[data-theme] body[data-surface="research"] .topbar-actions .search-box,
html[data-theme] body[data-surface="research"] .topbar-actions .search-box:focus-within {
  position: static; display: flex; flex: 1 1 170px; width: auto; max-width: 240px; min-width: 120px;
  height: 44px; padding: 0 12px; gap: 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-alt); color: var(--muted); box-shadow: none;
}
html[data-theme] body[data-surface="research"] .topbar-actions .search-box input {
  width: 100%; min-width: 0; font-size: 13px; opacity: 1; color: var(--ink);
}
html[data-theme] body[data-surface="research"] .topbar-actions .search-box:focus-within { border-color: var(--action); }
html[data-theme] body[data-surface="research"] .topbar-actions .primary-button { padding: 0 16px; }
html[data-theme] body[data-surface="research"] .topbar-actions .primary-button .ui-icon { filter: none; }
html[data-theme="light"] body[data-surface="research"] .topbar-actions .primary-button .ui-icon { filter: invert(1); }
html[data-theme] body[data-surface="research"] #work-logout { margin: 0 0 0 8px; padding-left: 16px; border-left: 1px solid var(--line); }
.workspace-logout-button { border: 0; padding: 0 8px; background: transparent; color: var(--muted); }
.workspace-logout-button:hover { color: var(--ink); background: var(--surface-alt); }
html[data-theme] body[data-surface="research"] .page-content { min-height: calc(100svh - 88px); display: flex; flex-direction: column; }
html[data-theme] body[data-surface="research"] .app-footer { margin-top: auto; padding-top: 40px; }
.workspace-footer-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 20px; border-top: 1px solid var(--line); }
html[data-theme] body[data-surface="research"] .app-footer .integration-notice {
  padding: 8px 0 0; margin: 0; border: 0; border-radius: 0; background: transparent;
  color: var(--muted); font-size: 12px; line-height: 1.6;
}
html[data-theme] body[data-surface="research"] .app-footer .integration-notice.is-error { color: #d67580; }
html[data-theme] body[data-surface="research"] .month-planning-toolbar h2 { margin: 0; }
@media (max-width:1280px) {
  html[data-theme] body[data-surface="research"] .topbar { flex-wrap: wrap; padding-inline: 24px; gap: 12px; }
  html[data-theme] body[data-surface="research"] .breadcrumb { width: 100%; }
  html[data-theme] body[data-surface="research"] .topbar-actions { flex: 1 1 100%; }
  html[data-theme] body[data-surface="research"] .topbar-actions .search-box { max-width: none; }
}
@media (max-width:760px) {
  html[data-theme] body[data-surface="research"] .topbar { padding: 16px; }
  html[data-theme] body[data-surface="research"] .topbar-actions { justify-content: flex-start; flex-wrap: wrap; }
  html[data-theme] body[data-surface="research"] .topbar-actions .search-box { flex: 1 1 100%; max-width: none; }
  html[data-theme] body[data-surface="research"] #work-logout { margin-left: auto; padding-left: 8px; }
  html[data-theme] body[data-surface="research"] .topbar-actions .secondary-button { padding-inline: 8px; }
  html[data-theme] body[data-surface="research"] .topbar-actions .primary-button { padding-inline: 10px; }
}
@media (max-width:420px) {
  html[data-theme] body[data-surface="research"] .topbar-actions { gap: 6px; }
  html[data-theme] body[data-surface="research"] .topbar-actions .workspace-hub-link { padding: 0; width: 44px; }
  html[data-theme] body[data-surface="research"] .workspace-hub-link span { display: none; }
  html[data-theme] body[data-surface="research"] #work-logout { border-left: 0; margin-left: auto; padding-left: 0; }
  .workspace-logout-button span { display: none; }
  .workspace-logout-button { width: 44px; }
  html[data-theme] body[data-surface="research"] .topbar-actions #add-task { flex: 1; }
}
@media (max-width:900px) {
  html[data-theme] body[data-surface="research"] .nav-icon { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
}
@media (max-width:360px) {
  html[data-theme] body[data-surface="research"] .topbar-actions { display: grid; grid-template-columns: minmax(0,1fr) 44px; }
  html[data-theme] body[data-surface="research"] .topbar-actions .search-box { grid-column: 1 / -1; }
  html[data-theme] body[data-surface="research"] .topbar-actions #work-logout { grid-column: 2; }
}
