:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #f1f2f4;
  --ink: #12151c;
  --muted: #6e7480;
  --line: #e3e5e9;
  --primary: #5d2caa;
  --primary-soft: #f2edfb;
  --group: #7650b9;
  --group-soft: #f2edfb;
  --shadow: 0 10px 28px rgba(20, 25, 38, .06);
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Noto Sans TC", system-ui, sans-serif; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.material-symbols-rounded { font-variation-settings: "FILL" 0, "wght" 420, "GRAD" 0, "opsz" 24; font-size: 22px; line-height: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { width: 100%; min-height: 100dvh; background: var(--surface); padding-bottom: calc(82px + var(--safe-bottom)); }
.app-header { position: sticky; z-index: 20; top: 0; height: 64px; padding: max(12px, env(safe-area-inset-top)) 18px 10px; display: flex; align-items: center; gap: 16px; background: rgba(255,255,255,.94); border-bottom: 1px solid rgba(227,229,233,.7); backdrop-filter: blur(18px); }
.wordmark { padding: 0; border: 0; background: none; font: 800 26px/1 "Inter", sans-serif; letter-spacing: -.04em; cursor: pointer; }
.desktop-search { display: none; }
.icon-button { position: relative; width: 44px; height: 44px; margin-left: auto; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); }
.icon-button i { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); border: 2px solid white; }
.icon-button.small { width: 38px; height: 38px; margin: 0; }

main { width: min(100%, 1180px); margin: 0 auto; }
main:focus { outline: none; }
.screen { display: none; padding: 12px 16px 28px; }
.screen.active { display: block; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font: 700 10px/1 "Inter", sans-serif; letter-spacing: .14em; }
.page-heading { margin: 8px 0 24px; }
.page-heading h1 { margin: 0; font-size: 31px; line-height: 1.2; letter-spacing: -.03em; }
.page-heading > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.view-switch { padding: 4px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.view-switch button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.view-switch button.active { color: white; box-shadow: 0 3px 10px rgba(20, 25, 38, .12); }
.view-switch button[data-view="groups"].active { background: #117fd1; }
.view-switch button[data-view="oshi"].active { background: var(--primary); }
.home-section { margin-top: 20px; }
.section-heading { margin-bottom: 10px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.section-heading h2, .digest-heading h2 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.02em; }
.text-button { min-height: 40px; display: inline-flex; align-items: center; gap: 1px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }
.text-button .material-symbols-rounded { font-size: 18px; }
.count { padding: 4px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: 12px; vertical-align: middle; }

.group-strip { margin: 0 -16px; padding: 0 16px 6px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.group-strip::-webkit-scrollbar { display: none; }
.group-tile { flex: 0 0 82px; min-height: 98px; padding: 10px 9px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; border: 1px solid color-mix(in srgb, var(--tile-color) 26%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--tile-color) 6%, white); text-align: left; cursor: pointer; scroll-snap-align: start; transition: transform .18s ease, box-shadow .18s ease; }
.group-tile:hover, .group-tile:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); outline: none; }
.group-monogram { min-width: 34px; height: 34px; padding: 0 6px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--tile-color) 13%, white); color: var(--tile-color); font: 800 14px "Inter", sans-serif; }
.group-tile b { display: block; font-size: 12px; line-height: 1.2; overflow-wrap: anywhere; }
.group-tile small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.group-tile.add { border-style: dashed; --tile-color: #767d88; align-items: center; justify-content: center; gap: 7px; text-align: center; color: var(--muted); }

.section-heading select { min-height: 38px; max-width: 142px; padding: 0 30px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); font-size: 12px; font-weight: 600; }
.feed-list { border: 1px solid var(--line); border-radius: 16px; background: white; overflow: hidden; }
.feed-row { width: 100%; min-height: 70px; padding: 9px 10px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 9px; align-items: center; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.feed-row:last-child { border-bottom: 0; }
.feed-row:hover { background: #fafafa; }
.feed-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--row-color); background: color-mix(in srgb, var(--row-color) 10%, white); }
.feed-main { min-width: 0; }
.feed-link { color: inherit; text-decoration: none; }
.feed-meta { margin-bottom: 5px; display: flex; gap: 7px; align-items: center; }
.group-label { padding: 3px 7px; border-radius: 6px; color: var(--row-color); background: color-mix(in srgb, var(--row-color) 9%, white); font-size: 10px; font-weight: 800; }
.feed-main b { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 12px; line-height: 1.35; }
.feed-main small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.feed-time { align-self: start; padding-top: 4px; color: var(--muted); font: 600 9px "Inter", sans-serif; white-space: nowrap; }
.feed-side { align-self: stretch; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; }
.save-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.save-button:hover { background: var(--surface-soft); }
.save-button.active { color: var(--primary); }
.save-button.active .material-symbols-rounded { font-variation-settings: "FILL" 1, "wght" 480, "GRAD" 0, "opsz" 24; }
.empty-state { padding: 30px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.wide-button { width: 100%; min-height: 40px; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 11px; background: white; font-size: 12px; font-weight: 700; cursor: pointer; }

.digest-section { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fbfbfc; box-shadow: var(--shadow); }
.digest-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.digest-heading p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.info-icon { color: var(--muted); font-size: 17px; vertical-align: -3px; }
.refresh-meta { display: flex; align-items: center; gap: 3px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.digest-grid { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.digest-item { min-height: 58px; padding: 9px; display: grid; grid-template-columns: 28px 1fr; gap: 7px; align-items: center; border: 1px solid var(--line); border-radius: 11px; background: white; }
.digest-item .material-symbols-rounded { color: var(--item-color); }
.digest-item b { display: block; font-size: 12px; }
.digest-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.digest-groups { margin-top: 11px; padding-top: 10px; display: flex; gap: 9px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.digest-group { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.digest-group i { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }

.mobile-search, .desktop-search { min-height: 46px; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--muted); }
.mobile-search { margin-bottom: 18px; display: flex; }
.mobile-search input, .desktop-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.directory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.directory-card { min-height: 150px; padding: 15px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid color-mix(in srgb, var(--card-color) 25%, var(--line)); border-radius: 15px; background: color-mix(in srgb, var(--card-color) 5%, white); text-align: left; cursor: pointer; }
.directory-card h2 { margin: 0; color: var(--card-color); font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.directory-card p { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.directory-card footer { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; }
.status-badge { padding: 3px 7px; border-radius: 6px; background: white; border: 1px solid var(--line); }

.group-topbar { min-height: 44px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.back-button, .switch-group { min-height: 40px; display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.switch-group { padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.back-button .material-symbols-rounded { font-size: 17px; }
.group-hero { margin: 0 -18px; padding: 34px 20px 26px; background: var(--group); color: white; }
.group-hero .eyebrow { color: rgba(255,255,255,.7); }
.group-hero h1 { margin: 0; font-size: 42px; line-height: 1.15; letter-spacing: -.04em; }
.group-hero p:last-child { margin: 10px 0 0; color: rgba(255,255,255,.82); font-size: 13px; }
.subnav { margin: 0 -18px 22px; padding: 0 18px; display: flex; gap: 20px; overflow-x: auto; border-bottom: 1px solid var(--line); background: white; scrollbar-width: none; }
.subnav button { min-height: 50px; padding: 0 2px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.subnav button.active { border-color: var(--group); color: var(--ink); }
.group-section { margin-top: 28px; }
.group-section:first-child { margin-top: 0; }
.group-section .section-heading { align-items: center; }
.content-list { border-top: 1px solid var(--line); }
.content-row { min-height: 62px; padding: 11px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.content-row b { display: block; font-size: 13px; }
.content-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.row-links { display: flex; gap: 5px; }
.micro-link { min-width: 38px; min-height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--group); font-size: 10px; font-weight: 800; text-decoration: none; }
.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.category-button { min-height: 82px; padding: 13px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; background: white; text-align: left; cursor: pointer; }
.category-button .material-symbols-rounded { color: var(--group); }
.category-button b { font-size: 12px; }
.member-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.member-card { min-height: 104px; padding: 13px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; background: white; text-align: left; cursor: pointer; }
.member-initial { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--group-soft); color: var(--group); font: 800 12px "Inter", sans-serif; }
.member-card b { font-size: 13px; }
.member-card small { color: var(--muted); font-size: 10px; }
.member-hero { padding: 20px 0 24px; border-bottom: 1px solid var(--line); }
.member-hero h1 { margin: 0; font-size: 34px; letter-spacing: -.03em; }
.member-hero p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.member-content { padding-top: 22px; }
.work-block { margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.work-block header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.work-block header span { color: var(--group); font-size: 10px; font-weight: 800; }
.work-block h3 { margin: 4px 0 0; font-size: 18px; }
.work-block header p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.fatal-error { max-width: 520px; margin: 80px auto; padding: 24px; }

.profile-groups { display: grid; gap: 12px; }
.profile-group { border: 1px solid var(--line); border-radius: 16px; background: white; overflow: hidden; }
.profile-group summary { min-height: 64px; padding: 0 15px; display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.profile-group summary::-webkit-details-marker { display: none; }
.profile-group summary::after { content: "expand_more"; margin-left: auto; font-family: "Material Symbols Rounded"; color: var(--muted); }
.profile-group[open] summary::after { content: "expand_less"; }
.profile-group summary i { width: 10px; height: 10px; border-radius: 50%; background: var(--profile-color); }
.profile-group summary b { font-size: 14px; }
.profile-group summary small { display: block; color: var(--muted); font-size: 10px; }
.member-options { padding: 0 15px 15px; display: grid; gap: 8px; }
.check-row { min-height: 44px; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--profile-color); }
.check-row em { margin-left: auto; color: var(--muted); font-size: 10px; font-style: normal; }
.form-actions { position: sticky; bottom: calc(72px + var(--safe-bottom)); margin: 18px -18px -32px; padding: 12px 18px; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.95); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
.primary-button { min-height: 46px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--ink); color: white; font-weight: 700; cursor: pointer; }
#saveStatus { color: var(--muted); font-size: 11px; }

.bottom-nav { position: fixed; z-index: 25; inset: auto 0 0; height: calc(70px + var(--safe-bottom)); padding: 7px 12px var(--safe-bottom); display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(18px); }
.bottom-nav button { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.bottom-nav b { font-size: 10px; }
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button.active .material-symbols-rounded { font-variation-settings: "FILL" 1, "wght" 520, "GRAD" 0, "opsz" 24; }

.group-dialog { width: min(100%, 520px); max-height: 78dvh; margin: auto 0 0; padding: 0; border: 0; border-radius: 20px 20px 0 0; background: white; box-shadow: 0 -16px 50px rgba(20,25,38,.15); }
.group-dialog::backdrop { background: rgba(15,18,24,.32); backdrop-filter: blur(2px); }
.group-dialog form { padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); }
.dialog-handle { width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 99px; background: #cdd0d5; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.dialog-heading h2 { margin: 0; font-size: 21px; }
.dialog-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dialog-group { min-height: 48px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 12px; font-weight: 700; cursor: pointer; }
.dialog-group i { width: 8px; height: 8px; border-radius: 50%; background: var(--dialog-color); }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(88px + var(--safe-bottom)); padding: 10px 14px; border-radius: 10px; background: var(--ink); color: white; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 760px) {
  .app-shell { padding: 0 0 40px; }
  .app-header { height: 82px; padding: 14px 28px; }
  .desktop-search { width: min(480px, 48vw); margin-left: auto; display: flex; }
  .icon-button { margin-left: 0; }
  .screen { padding: 28px; }
  .bottom-nav { position: sticky; top: 82px; bottom: auto; width: min(100%, 1180px); height: 58px; margin: 0 auto; padding: 0 28px; display: flex; gap: 12px; border: 0; border-bottom: 1px solid var(--line); }
  .bottom-nav button { min-width: 110px; flex-direction: row; gap: 8px; }
  .bottom-nav b { font-size: 12px; }
  .view-switch { width: 390px; }
  .group-strip { margin: 0; padding: 0 0 8px; }
  .group-tile { flex-basis: 132px; }
  .group-tile { min-height: 138px; padding: 14px 12px; }
  .home-section { margin-top: 38px; }
  .update-section, .digest-section { width: calc(65% - 12px); }
  .digest-section { position: absolute; top: 267px; right: 28px; width: calc(35% - 30px); margin-top: 0; }
  #homeScreen { position: relative; }
  .digest-grid { grid-template-columns: 1fr; }
  .directory-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .member-grid { grid-template-columns: repeat(4, 1fr); }
  .group-hero { margin: 0; padding: 44px 34px 34px; border-radius: 18px 18px 0 0; }
  .subnav { margin: 0 0 28px; padding: 0 28px; }
  .group-topbar { margin-top: -10px; }
  .group-dialog { margin: auto; border-radius: 20px; }
  .form-actions { bottom: 0; margin-inline: 0; }
}

@media (min-width: 1080px) {
  .app-header { padding-inline: max(28px, calc((100vw - 1180px) / 2 + 28px)); }
  .home-section.update-section { width: calc(68% - 14px); }
  .digest-section { width: calc(32% - 28px); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
