/* Shared optical surfaces; content opacity remains owned by the existing --panel-fill setting. */
:root {
  --primary-color: #22796b;
  --accent-soft: #dcefe9;
  --bg: #e9eeed;
  --surface: #fbfdfc;
  --surface-muted: #f1f5f4;
  --panel-radius: 24px;
  --card-radius: 20px;
  --control-radius: 12px;
  --panel-surface: color-mix(in srgb, var(--surface) var(--panel-fill, 85%), transparent);
  --text: #25322f;
  --muted: #60716c;
  --border: #6c877b26;
  --danger: #b84450;
  --glass-fill: #f8fffc9c;
  --glass-edge: #ffffffc9;
  --glass-shadow: 0 8px 28px #263f3d12, inset 0 1px 0 #ffffffba, inset 0 -1px 0 #536b6314;
  --wallpaper: none;
  --header-height: 64px;
  --rail-width: 64px;
  --dock-space: calc(88px + env(safe-area-inset-bottom, 0px));
  --shadow: 0 24px 70px #172c3830;
  color-scheme: light;
}
.dark {
  --accent-soft: #314843;
  --bg: #202727;
  --surface: #242c2d;
  --surface-muted: #2e3637;
  --text: #eef4f2;
  --muted: #b4c2bf;
  --border: #d0e4da24;
  --danger: #ff9a9f;
  --glass-fill: #273232b8;
  --glass-edge: #e4fff42e;
  --glass-shadow: 0 8px 28px #0000002b, inset 0 1px 0 #effff32b, inset 0 -1px 0 #0003;
  --shadow: 0 24px 70px #0006;
  --link-color: color-mix(in srgb, var(--primary-color) 35%, var(--text));
  color-scheme: dark;
}
body {
  background: var(--bg);
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--wallpaper) center / cover no-repeat;
  opacity: 0.28;
  pointer-events: none;
}
body.has-custom-bg::before {
  display: none;
}
body.dark::before,
.dark body::before {
  opacity: 0.18;
}
/* Cached custom wallpaper is available before the body/module scripts are parsed. */
html[data-wallpaper='custom'] body::before {
  opacity: 1;
}
.glass-filter-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}
.liquid-surface {
  position: relative;
  isolation: isolate;
}
.liquid-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: -1;
  pointer-events: none;
  background: var(--wallpaper) center 65% / cover no-repeat;
  opacity: 0.09;
}
.rich-effects .liquid-surface::before {
  filter: url('#liquid-refraction');
}
.app-header,
.nav-rail,
.admin-sidebar,
.auth-card,
.auth-glass,
dialog {
  backdrop-filter: blur(24px) saturate(145%);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
}
.app-header {
  height: var(--header-height);
  padding: 0 24px;
  border-width: 0 0 1px;
  background: var(--glass-fill);
}
.brand {
  font-size: 18px;
  gap: 11px;
}
.brand-mark {
  width: 34px;
  height: 36px;
  border-radius: 12px;
  box-shadow:
    inset 0 1px 1px #ffffff70,
    0 3px 9px #19493920;
}
.brand-mark svg {
  width: 21px;
}
.header-caption {
  font-size: 12px;
}
.header-search {
  width: 240px;
  border-radius: 999px;
  padding: 3px 14px;
  background: #ffffff38;
  border: 1px solid var(--glass-edge);
}
.profile-button {
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
}
.profile-button:hover {
  background: var(--accent-soft);
}
.icon-btn,
.subtle-btn,
.primary-btn,
.text-btn,
.admin-nav,
:where(input:not([type='checkbox']):not([type='color']):not([type='range']), select, textarea) {
  border-radius: 12px;
}
.icon-btn {
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease;
}
.primary-btn {
  min-height: 38px;
  box-shadow:
    inset 0 1px 0 #ffffff40,
    0 4px 10px #234e3921;
}
.subtle-btn {
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  border-color: var(--glass-edge);
}
.segmented {
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  border: 1px solid var(--border);
}
.segmented button {
  border-radius: 999px;
  min-height: 30px;
  padding: 5px 12px;
  font-size: 12px;
}
.segmented button[aria-selected='true'] {
  box-shadow: var(--glass-shadow);
}
.dark .segmented button[aria-selected='true'] {
  color: #b0ead7;
}
.dark
  :is(.nav-rail .active, .admin-nav.active, .topic-link, .read-more, .auth-toggle, .auth-footer a) {
  color: var(--link-color);
}
.switch-track {
  width: 34px;
  height: 20px;
}
.switch-track::after {
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
}
.switch-label input:checked + .switch-track::after {
  transform: translateX(14px);
}
.dock-label,
.dock-indicator,
#mobileSaveSlot,
#toolsToggle {
  display: none;
}
.app-shell {
  grid-template-columns: var(--rail-width) clamp(240px, 20vw, 320px) minmax(0, 1fr) clamp(
      220px,
      18vw,
      280px
    );
  grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - var(--header-height));
  min-height: 0;
  gap: 0;
  padding: 0;
}
.nav-rail {
  border-width: 0 1px 0 0;
  padding: 22px 8px 18px;
  gap: 12px;
  background: var(--glass-fill);
}
.nav-rail .icon-btn {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
  border-radius: 16px;
}
.nav-rail .active {
  background: var(--accent-soft);
  box-shadow: var(--glass-shadow);
}
.nav-rail .active::before {
  display: none;
}
.square-panel {
  padding: 26px 18px 0;
  border: 0;
}
.diary-page .square-panel {
  background: transparent;
}
.square-filter {
  padding: 17px 0;
}
.eyebrow {
  color: var(--muted);
}
.panel-heading h2 {
  font-size: 19px;
}
.note-card {
  border-radius: var(--card-radius);
  padding: 18px;
  border: 1px solid var(--glass-edge);
  box-shadow:
    0 4px 16px #31463b08,
    inset 0 1px 0 #ffffff50;
  transition:
    border-color 0.18s,
    box-shadow 0.18s;
}
.author-link,
.note-title-link {
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.author-link {
  font-weight: 600;
}
.author-info > .author-link {
  display: block;
  font-size: 12px;
}
.note-card {
  cursor: pointer;
}
.author-link:hover,
.note-title-link:hover {
  color: var(--primary-color);
}
.author-link:focus-visible,
.note-title-link:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 3px;
  border-radius: 4px;
}
.card-author > .author-link {
  display: flex;
  flex-shrink: 0;
}
.author-info {
  min-width: 0;
}
.reader-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.post-view-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.post-view-count svg {
  width: 14px;
  height: 14px;
}
.card-footer {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.reader-header > .post-view-count {
  margin-bottom: 12px;
}
.pinned-note > .post-view-count {
  margin-left: auto;
}
.dark .share-note {
  color: var(--text);
}
.share-link {
  width: 100%;
  margin-bottom: 12px;
}
.note-card:hover {
  border-color: #80b5a9;
  box-shadow: 0 6px 22px #31463b16;
}
/* A bounded sticky stack keeps featured titles visible without covering the entire mobile feed. */
.square-pinned {
  position: sticky;
  top: 0;
  z-index: 3;
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  max-height: min(192px, 32dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0 12px;
  margin-bottom: 8px;
}
.pinned-note {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid #d1b46c;
  border-left: 4px solid #bc9135;
  border-radius: 12px;
  background: rgba(250, 253, 252, 0.94);
  backdrop-filter: blur(24px);
  box-shadow: 0 4px 16px #173c2920;
  color: var(--text);
  text-decoration: none;
}
.pinned-note svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  color: #8b691e;
}
.pinned-note strong {
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pinned-note:hover,
.pinned-note:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}
.dark .pinned-note {
  background: rgba(34, 47, 45, 0.96);
  border-color: #ba9c55;
}
.dark .pinned-note svg {
  color: #e6c575;
}
.feed-sentinel {
  height: 1px;
  flex: 0 0 1px;
}
.feed-status {
  text-align: center;
  margin: 12px 0;
  font-size: 12px;
  flex: 0 0 auto;
}
.guest-mode .square-pinned {
  width: 100%;
}
.admin-badge.pinned {
  color: #77530c;
  background: #fbefc8;
  margin-right: 8px;
}
.dark .admin-badge.pinned {
  color: #f3d988;
  background: #514528;
}
.note-card:nth-child(3n + 2) .card-author .avatar {
  background: #f4dfd6;
}
.note-card:nth-child(3n) .card-author .avatar {
  background: #e9e4cb;
}
.card-title {
  font-size: 16px;
  line-height: 1.65;
}
.card-preview {
  color: var(--muted);
  line-height: 1.9;
}
.card-tags {
  gap: 7px;
}
.note-card:nth-child(3n + 2) .card-tags {
  color: #a55648;
}
.note-card:nth-child(3n) .card-tags {
  color: #8d7428;
}
.dark .note-card:nth-child(3n + 2) .card-tags {
  color: #edb2a2;
}
.dark .note-card:nth-child(3n) .card-tags {
  color: #dac681;
}
.context-panel {
  position: static;
  width: auto;
  max-width: none;
  padding: 28px 20px 16px;
  border: 0;
  background: transparent;
}
.diary-page .context-panel {
  background: color-mix(in srgb, var(--surface) var(--panel-fill, 85%), transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.context-header h2 {
  font-size: 16px;
}
.calendar-day {
  border-radius: 50%;
}
.calendar-day.today,
.calendar-day[aria-current='date'] {
  box-shadow:
    inset 0 1px 0 #ffffff50,
    0 3px 8px #1a66502a;
}
.stats-section {
  border-radius: 0;
  padding-top: 24px;
}
.stat-bar {
  background: #95a89d26;
}
.stat-bar span {
  border-radius: 4px;
}
.editor-panel {
  margin: 14px 0;
  border: 1px solid var(--glass-edge);
  border-radius: 24px;
  padding: 20px 26px 0;
  box-shadow: var(--glass-shadow);
  overflow: auto;
  min-height: 0;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.editor-heading {
  order: 0;
  margin-bottom: 12px;
  gap: 10px;
}
.editor-heading h1 {
  font-size: 19px;
}
.editor-heading .breadcrumb {
  margin-bottom: 5px;
  font-size: 11px;
}
.editor-heading .icon-btn {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}
.title-field {
  order: 1;
  margin: 0 0 10px;
}
.title-field input {
  font-size: 26px;
  font-weight: 650;
  line-height: 1.5;
}
.note-details {
  order: 2;
  min-width: 0;
  margin: 0 0 12px;
}
.note-details > summary,
.publishing-details > summary {
  display: none;
}
.note-meta {
  gap: 12px;
}
.note-meta input:not([type='checkbox']) {
  font-size: 12px;
}
.note-meta .date-field input {
  width: 118px;
}
.mood-row {
  padding: 10px 0 0;
  border: 0;
  gap: 8px;
}
.mood-selector {
  gap: 4px;
}
.mood-btn {
  width: 28px;
  height: 28px;
  background: #a0b3a812;
}
.mood-btn[aria-pressed='true'] {
  box-shadow: var(--glass-shadow);
}
.tags-field {
  margin: 7px 0 0;
}
.tags-field input {
  font-size: 12px;
  padding: 0 !important;
}
.writing-surface {
  order: 3;
  flex: 1 0 220px;
  min-height: 220px;
  border-radius: 18px;
  border-color: var(--border);
  background: color-mix(in srgb, var(--surface) 35%, transparent);
}
.editor-tools {
  padding: 6px 10px;
}
.markdown-toolbar {
  gap: 2px;
}
.markdown-toolbar .icon-btn {
  width: 28px;
  flex-basis: 28px;
  height: 30px;
  border-radius: 8px;
}
.editor-mode-row {
  padding: 6px 10px;
}
#editorContent,
#previewContent {
  padding: 20px max(22px, calc((100% - 820px) / 2));
  font-size: 15px;
  line-height: 1.95;
}
.editor-body[data-mode='split'] :is(#editorContent, #previewContent) {
  padding: 18px 22px;
}
.publishing-details {
  order: 4;
}
.publish-options {
  padding: 10px 0;
  border: 0;
  font-size: 12px;
}
.publication-warning {
  order: 5;
}
.editor-footer {
  order: 6;
  padding: 10px 0 14px;
  border-top: 1px solid var(--border);
}
.editor-status {
  font-size: 11px;
}
.password-field {
  border-radius: 12px;
}
.menu-content {
  z-index: 45;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
dialog {
  border-radius: var(--panel-radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}
dialog::backdrop {
  background: #172d324d;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.dialog-header {
  padding: 18px 24px;
  background: var(--glass-fill);
}
.dialog-body {
  padding: 24px;
}
.note-dialog {
  width: min(1080px, calc(100vw - 48px));
}
.reader-grid .markdown-body {
  max-width: 780px;
  font-size: 16px;
}
.profile-dialog,
.media-dialog,
.search-dialog {
  border-radius: 24px;
}
.avatar-editor {
  padding-bottom: 18px;
}
.avatar-large {
  border: 3px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
}
.auth-page {
  background: var(--bg);
}
.auth-card {
  padding: 36px;
  border-radius: var(--panel-radius);
}
.auth-glass {
  border-radius: var(--panel-radius);
  padding: 34px;
  background: var(--glass-fill);
}
.dark .auth-glass {
  background: var(--glass-fill);
}
.guest-auth-dialog {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.guest-mode .square-panel {
  padding: 30px;
}
.guest-mode .panel-heading h2 {
  font-size: 28px;
}
.guest-mode .note-card {
  min-height: 232px;
}
.guest-mode .square-feed {
  gap: 20px;
}
.auth-particles {
  display: none;
}
.account-panel {
  padding: 28px;
  min-width: 0;
  overflow: auto;
}
.account-panel h1 {
  font-size: 26px;
}
.account-identity {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 30px 0;
}
.account-identity .avatar {
  width: 72px;
  height: 72px;
  border: 3px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
}
.account-identity h2 {
  overflow-wrap: anywhere;
}
.account-settings {
  border-top: 1px solid var(--border);
}
.account-settings > button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 10px 4px;
}
.account-settings > button > span:first-of-type {
  flex: 1;
}
.setting-value {
  color: var(--muted);
  font-size: 12px;
}
.account-settings [role='switch'] .setting-value {
  position: relative;
  width: 42px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #8fa39866;
  font-size: 0;
}
.account-settings [role='switch'] .setting-value::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px #1e362a26;
  transition: transform 0.18s;
}
.account-settings [role='switch'][aria-checked='true'] .setting-value {
  background: var(--primary-color);
}
.account-settings [role='switch'][aria-checked='true'] .setting-value::after {
  transform: translateX(16px);
}
.console-page {
  --console-sidebar: 224px;
}
.console-header {
  height: var(--header-height);
}
.admin-sidebar {
  /* Optical surfaces must not change this sidebar's layout positioning. */
  position: fixed;
  top: calc(var(--header-height) + 16px);
  left: 16px;
  bottom: 16px;
  width: calc(var(--console-sidebar) - 16px);
  padding: 26px 16px;
  background: var(--glass-fill);
  border-width: 1px;
  border-radius: var(--panel-radius);
}
.admin-nav {
  min-height: 46px;
  border-radius: 14px;
}
.admin-nav.active {
  box-shadow: var(--glass-shadow);
}
.console-main {
  margin: 16px 16px 16px calc(var(--console-sidebar) + 16px);
  min-height: calc(100dvh - var(--header-height) - 32px);
  background: var(--panel-surface);
  border-radius: var(--panel-radius);
}
.console-main > :is(.console-page-heading, .form-message, [data-console-view]) {
  max-width: 1680px;
  margin-inline: auto;
}
.admin-filter,
.community-admin-filter {
  padding: 12px;
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
  background: var(--glass-fill);
  backdrop-filter: blur(16px);
}
.metric dt {
  color: var(--muted);
}
.metric:nth-child(2) dt svg {
  color: #c06a58;
}
.metric:nth-child(3) dt svg {
  color: #aa892f;
}
.metric:nth-child(4) dt svg {
  color: #718eb0;
}
.admin-table {
  background: transparent;
}
.admin-table-wrap {
  border-radius: 14px;
}
.admin-badge {
  border-radius: 999px;
}
.toast {
  border-radius: 14px;
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .console-page {
    --console-sidebar: 200px;
  }
  .app-shell {
    grid-template-columns: var(--rail-width) 250px minmax(0, 1fr);
  }
  .context-panel {
    display: none;
    position: fixed;
    right: 16px;
    top: calc(var(--header-height) + 12px);
    bottom: 16px;
    width: 290px;
    border-radius: 24px;
    background: var(--surface);
    z-index: 40;
    box-shadow: var(--shadow);
  }
  .diary-page .context-panel {
    background: var(--surface);
  }
  .context-panel.drawer-open {
    display: flex;
  }
  .close-context {
    display: inline-flex;
  }
  .editor-panel {
    margin-right: 14px;
    padding-left: 20px;
    padding-right: 20px;
  }
  .drawer-backdrop:not([hidden]) {
    top: var(--header-height);
  }
}
@media (min-width: 1280px) {
  .context-panel {
    display: flex;
  }
  .close-context {
    display: none;
  }
}
@media (min-width: 1024px) and (max-height: 780px) {
  .editor-panel {
    padding-top: 14px;
    margin-top: 10px;
    margin-bottom: 10px;
  }
  .editor-heading .breadcrumb {
    display: none;
  }
  .editor-heading {
    margin-bottom: 8px;
  }
  .title-field input {
    font-size: 23px;
  }
  .title-field {
    margin-bottom: 7px;
  }
  .note-details {
    margin-bottom: 8px;
  }
  .mood-row {
    padding-top: 7px;
  }
  .tags-field {
    margin-top: 4px;
  }
  .editor-footer {
    padding-top: 8px;
    padding-bottom: 10px;
  }
}
@media (min-width: 1024px) and (max-height: 650px) {
  .editor-panel {
    padding-top: 10px;
  }
  .editor-heading h1 {
    font-size: 16px;
  }
  .editor-heading {
    margin-bottom: 4px;
  }
  .title-field input {
    font-size: 21px;
  }
  .mood-row {
    padding: 4px 0 0;
  }
  .writing-surface {
    min-height: 190px;
    flex-basis: 190px;
  }
}

/* Mobile is a distinct shell, not a squeezed desktop. The same content nodes are retained. */
@media (max-width: 1023px) {
  :root {
    --header-height: 60px;
  }
  .app-header {
    height: var(--header-height);
    padding: 0 16px;
    gap: 12px;
  }
  .header-caption,
  .header-contact,
  .header-search,
  .profile-button > svg,
  .profile-button > span {
    display: none;
  }
  .brand {
    font-size: 17px;
    gap: 9px;
  }
  .brand > span:last-child {
    max-width: 180px;
  }
  .brand-mark {
    width: 31px;
    height: 33px;
    border-radius: 11px;
  }
  .header-actions {
    gap: 5px;
  }
  .mobile-only {
    display: inline-flex;
  }
  .profile-button {
    padding: 4px;
  }
  .profile-button .avatar {
    width: 30px;
    height: 30px;
  }
  .diary-page {
    overflow: hidden;
  }
  .app-shell,
  .guest-mode .app-shell {
    display: block;
    height: calc(100dvh - var(--header-height));
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }
  .nav-rail,
  .admin-sidebar {
    position: fixed;
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    width: auto;
    max-width: 560px;
    margin: 0 auto;
    height: 64px;
    min-height: 64px;
    border-radius: 999px;
    padding: 5px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    overflow: hidden;
    z-index: 50;
    background: var(--glass-fill);
    border: 1px solid var(--glass-edge);
    box-shadow:
      0 8px 32px #183b3b2e,
      inset 0 1px 1px #ffffffc4,
      inset 0 -1px 1px #46776a33;
  }
  .diary-page .nav-rail {
    background: var(--glass-fill);
  }
  .nav-rail > :is(.rail-spacer, #themeToggle, #logoutBtn, [data-effects-toggle]),
  .sidebar-heading,
  .sidebar-bottom {
    display: none;
  }
  .nav-rail .icon-btn,
  .admin-sidebar .admin-nav {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 3px 0;
    width: 100%;
    height: 52px;
    min-height: 52px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.3;
    background: transparent;
    box-shadow: none;
    color: var(--muted);
  }
  .nav-rail .active,
  .admin-sidebar .admin-nav.active {
    color: var(--primary-color);
    font-weight: 650;
  }
  .dark .nav-rail .active,
  .dark .admin-sidebar .admin-nav.active {
    color: #a3e8d4;
  }
  .nav-rail .icon-btn svg,
  .admin-nav svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }
  .dock-label {
    display: block;
  }
  .dock-indicator {
    display: block;
    position: absolute;
    left: 5px;
    top: 5px;
    width: calc((100% - 10px) / 4);
    height: 52px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 69%, transparent);
    border: 1px solid var(--glass-edge);
    box-shadow:
      inset 0 1px 1px #fff9,
      inset 0 -1px 2px #6d9a8155,
      0 2px 8px #20443219;
    transform: translateX(calc(var(--dock-index, 0) * 100%));
    transition: transform 0.28s cubic-bezier(0.2, 0.85, 0.25, 1.12);
    pointer-events: none;
  }
  .editor-panel,
  .square-panel,
  .context-panel,
  .account-panel,
  .guest-mode .square-panel {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    grid-column: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 18px 20px var(--dock-space);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: auto;
  }
  .diary-page .editor-panel {
    background: color-mix(in srgb, var(--surface) var(--panel-fill, 85%), transparent);
  }
  .diary-page .context-panel,
  .account-panel {
    background: color-mix(in srgb, var(--surface) 80%, transparent);
  }
  .editor-panel {
    display: flex;
  }
  .square-panel,
  .context-panel {
    display: none;
  }
  .diary-page[data-view='notes'] :is(#squarePanel, #contextPanel, #accountPanel),
  .diary-page[data-view='square'] :is(#editorPanel, #contextPanel, #accountPanel),
  .diary-page[data-view='calendar'] :is(#editorPanel, #squarePanel, #accountPanel),
  .diary-page[data-view='account'] :is(#editorPanel, #squarePanel, #contextPanel) {
    display: none;
  }
  .diary-page[data-view='square'] #squarePanel,
  .guest-mode #squarePanel,
  .diary-page[data-view='calendar'] #contextPanel {
    display: flex;
  }
  .diary-page[data-view='account'] #accountPanel {
    display: block;
  }
  .close-drawer,
  .close-context,
  .drawer-backdrop:not([hidden]) {
    display: none;
  }
  .editor-heading {
    position: sticky;
    top: -18px;
    z-index: 10;
    min-height: 56px;
    padding: 8px 0;
    margin: -10px 0 14px;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .editor-heading h1 {
    font-size: 16px;
  }
  .editor-heading .breadcrumb,
  #todayBtn {
    display: none;
  }
  .editor-heading .inline-actions {
    gap: 6px;
  }
  .editor-heading .icon-btn {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }
  #mobileSaveSlot {
    display: inline-flex;
  }
  #desktopSaveSlot {
    display: none;
  }
  #saveBtn {
    min-height: 38px;
    padding: 8px 13px;
    font-size: 12px;
    gap: 5px;
  }
  #saveBtn svg {
    width: 16px;
    height: 16px;
  }
  .title-field {
    margin: 0 0 14px;
  }
  .title-field input {
    font-size: 25px;
  }
  .note-details {
    margin-bottom: 14px;
  }
  .note-details > summary,
  .publishing-details > summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
  }
  .note-details > summary::-webkit-details-marker,
  .publishing-details > summary::-webkit-details-marker {
    display: none;
  }
  .note-details > summary svg,
  .publishing-details > summary svg {
    width: 17px;
    height: 17px;
  }
  .note-details > summary svg:last-child,
  .publishing-details > summary svg:last-child {
    margin-left: auto;
    width: 14px;
  }
  details[open] > summary svg:last-child {
    transform: rotate(180deg);
  }
  .note-meta {
    padding: 8px 0;
    gap: 12px;
  }
  .note-meta input:not([type='checkbox']) {
    font-size: 16px;
  }
  .note-meta .date-field input {
    width: 140px;
  }
  .privacy-badge {
    margin-left: 0;
    font-size: 11px;
  }
  .mood-row {
    display: block;
    padding: 8px 0;
  }
  .field-caption {
    display: block;
    font-size: 12px;
    padding: 0 0 8px;
  }
  .mood-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
  }
  .mood-btn {
    width: 44px;
    height: 44px;
  }
  .mood-btn svg {
    width: 23px;
    height: 23px;
  }
  .tags-field {
    margin: 8px 0;
  }
  .tags-field input {
    font-size: 16px;
    min-height: 40px;
  }
  .writing-surface {
    flex: 1 0 auto;
    min-height: 340px;
    overflow: clip;
    border-radius: 18px;
  }
  .editor-tools {
    position: relative;
    display: flex;
    padding: 5px;
    gap: 2px;
  }
  .markdown-toolbar {
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
    overflow: auto;
    scrollbar-width: none;
  }
  .markdown-toolbar::-webkit-scrollbar {
    display: none;
  }
  .tool-group {
    flex-shrink: 0;
    padding-right: 2px;
    margin-right: 2px;
  }
  .markdown-toolbar .icon-btn {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }
  .markdown-toolbar svg {
    width: 18px;
    height: 18px;
  }
  .markdown-toolbar select {
    font-size: 14px;
    min-height: 40px;
    width: 60px;
  }
  #toolsToggle {
    display: inline-flex;
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    background: var(--surface);
  }
  .tools-expanded .markdown-toolbar {
    flex-wrap: wrap;
  }
  .editor-mode-row {
    padding: 7px;
  }
  .editor-mode-row > .icon-btn {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }
  .segmented button {
    min-height: 36px;
    font-size: 12px;
    padding: 5px 10px;
  }
  .editor-mode-row .segmented button svg {
    width: 13px;
    height: 13px;
  }
  .editor-body {
    flex: 1;
    grid-template-rows: minmax(0, 1fr);
    min-height: 220px;
  }
  .editor-body[data-mode='split'] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
    min-height: 430px;
  }
  #editorContent,
  #previewContent {
    height: 100%;
    min-height: 0;
    max-height: none;
    padding: 18px;
    font-size: 16px;
    line-height: 1.95;
    resize: none;
    overflow: auto;
  }
  .publishing-details {
    margin-top: 10px;
  }
  .publish-options {
    gap: 14px;
    font-size: 12px;
    padding: 10px 0;
  }
  .password-field input {
    font-size: 16px;
  }
  .editor-footer {
    padding: 10px 0 12px;
  }
  .editor-status {
    font-size: 11px;
  }
  .context-header h2 {
    font-size: 24px;
  }
  .calendar-section {
    padding-top: 20px;
  }
  .calendar-grid {
    gap: 8px;
  }
  .calendar-day {
    min-height: 44px;
    font-size: 14px;
    aspect-ratio: 1;
    max-height: 64px;
  }
  .calendar-week {
    margin-bottom: 10px;
  }
  .calendar-heading {
    margin-bottom: 20px;
  }
  .context-panel .calendar-day {
    font-size: 14px;
  }
  .stats-section {
    margin-top: 26px;
  }
  .context-footer {
    padding-top: 24px;
  }
  .square-panel .panel-heading h2 {
    font-size: 25px;
  }
  .square-panel .square-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 16px;
    align-content: start;
    flex: 0 0 auto;
    overflow: visible;
  }
  .note-card {
    padding: 20px;
    margin: 0;
  }
  .square-footer {
    display: none;
  }
  .guest-mode .square-panel {
    padding: 24px 20px var(--dock-space);
  }
  .guest-mode .panel-heading h2 {
    font-size: 26px;
  }
  .guest-mode .profile-button span {
    display: none;
  }
  .guest-mode .note-card {
    padding: 20px;
  }
  dialog {
    width: min(560px, calc(100vw - 20px));
    max-height: calc(100dvh - 24px);
    border-radius: 24px;
  }
  .profile-dialog,
  .media-dialog,
  .search-dialog,
  .confirm-dialog {
    margin: auto auto 0;
    width: min(560px, 100%);
    border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .dialog-header {
    padding: 14px 20px;
  }
  .dialog-body,
  .note-dialog .dialog-body {
    padding: 20px;
  }
  .note-dialog {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .note-dialog .dialog-header {
    padding-top: max(14px, env(safe-area-inset-top, 0px));
  }
  .note-dialog .dialog-body {
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
  .form-stack input:not([type='checkbox']):not([type='file']),
  .comment-inputs textarea,
  .search-box input {
    font-size: 16px;
  }
  .guest-auth-dialog {
    max-width: 100%;
    width: 100%;
    max-height: 100dvh;
  }
  .auth-glass {
    padding: 30px 24px;
  }
  .auth-card {
    padding: 30px 24px;
  }
  .console-page {
    --console-sidebar: 0px;
  }
  .console-header {
    height: var(--header-height);
    padding: 0 14px;
  }
  #adminMenuToggle {
    display: none;
  }
  .console-label,
  .admin-username {
    display: none;
  }
  .console-header .return-site {
    min-height: 38px;
    padding: 6px;
  }
  .console-header .return-site span {
    display: none;
  }
  .admin-sidebar {
    transform: none;
    display: block;
  }
  .admin-sidebar nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
  }
  .admin-sidebar.open {
    width: auto;
  }
  .admin-nav-backdrop {
    display: none !important;
  }
  .console-main {
    /* Only the scroll tail clears the floating Dock; the panel fills the viewport behind it. */
    padding: 24px 18px calc(var(--dock-space) + 24px);
    margin: 8px;
    min-height: calc(100dvh - var(--header-height) - 16px);
  }
  .console-page-heading h1 {
    font-size: 24px;
  }
  .overview-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-filter,
  .community-admin-filter {
    flex-wrap: wrap;
    padding: 10px;
  }
  .toast {
    bottom: calc(var(--dock-space) + 8px);
    max-width: calc(100vw - 32px);
  }
  .keyboard-open .nav-rail,
  .keyboard-open .admin-sidebar {
    display: none;
  }
  .keyboard-open .app-shell {
    position: fixed;
    top: calc(var(--visual-top) + var(--header-height));
    left: 0;
    right: 0;
    height: calc(var(--visual-height) - var(--header-height));
  }
  .keyboard-open .app-header {
    position: fixed;
    top: var(--visual-top);
    left: 0;
    right: 0;
  }
  .keyboard-open .editor-panel {
    padding-bottom: 16px;
  }
  .keyboard-open :is(.profile-dialog, .media-dialog, .search-dialog) {
    max-height: calc(var(--visual-height) - 16px);
  }
  .keyboard-open .guest-auth-dialog {
    top: var(--visual-top);
    bottom: auto;
    height: var(--visual-height);
    max-height: var(--visual-height);
    padding: 12px;
  }
  .keyboard-open .auth-glass,
  .keyboard-open .session-lock-dialog {
    max-height: calc(var(--visual-height) - 24px);
  }
  .keyboard-open .auth-glass {
    padding-top: 18px;
    padding-bottom: 18px;
  }
}
@media (max-width: 359px) {
  .app-header {
    padding: 0 12px;
    gap: 6px;
  }
  .brand {
    font-size: 15px;
  }
  .brand > span:last-child {
    max-width: 130px;
  }
  .editor-panel {
    padding-left: 14px;
    padding-right: 14px;
  }
  .title-field input {
    font-size: 23px;
  }
  #saveBtn {
    padding: 8px 10px;
  }
  #saveBtn span {
    display: none;
  }
  #saveBtn::after {
    content: '保存';
  }
  .editor-mode-row .segmented button {
    padding: 5px 8px;
  }
  .console-header #adminAvatar {
    display: none;
  }
}
@media (max-height: 520px) and (max-width: 1023px) {
  :root {
    --header-height: 50px;
  }
  .editor-heading {
    margin-bottom: 6px;
  }
  .auth-glass {
    padding: 18px 24px;
  }
}
.simple-effects .liquid-surface::before {
  display: none;
}
.simple-effects
  :is(
    .app-header,
    .nav-rail,
    .admin-sidebar,
    .auth-card,
    .auth-glass,
    dialog,
    .admin-filter,
    .community-admin-filter
  ) {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.simple-effects .dock-indicator {
  transition: none;
}
.simple-effects .editor-panel,
.simple-effects .diary-page .context-panel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.simple-effects .nav-rail,
.simple-effects .admin-sidebar {
  background: var(--surface);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-header,
  .diary-page .nav-rail,
  .admin-sidebar,
  .auth-glass,
  dialog {
    background: var(--surface);
  }
  .liquid-surface::before {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .liquid-surface::before {
    filter: none;
  }
  .dock-indicator {
    transition: none;
  }
}
@media (max-width: 1023px) {
  /* A shared minimum prevents focus zoom, including fields in dynamically created dialogs.
     This overrides legacy small-font selectors without disabling user pinch zoom. */
  input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='color']):not(
      [type='file']
    ),
  textarea,
  select,
  [contenteditable='true'] {
    font-size: max(16px, var(--mobile-input-size, 16px)) !important;
    min-width: 0;
    scroll-margin-block: 16px;
  }
  .title-field input {
    --mobile-input-size: 22px;
  }
  .keyboard-open dialog[open]:not(.guest-auth-dialog) {
    position: fixed;
    top: calc(var(--visual-top, 0px) + 8px);
    bottom: auto;
    margin-top: 0;
    margin-bottom: 0;
    max-height: calc(var(--visual-height, 100dvh) - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 12px;
  }
}
@media print {
  body::before,
  .liquid-surface::before,
  .nav-rail,
  .account-panel,
  .note-details,
  .publishing-details {
    display: none !important;
  }
  .editor-panel {
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}
.site-notice-ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 48px;
  min-height: 48px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius, 12px);
  background: var(--surface);
}
.site-notice-ticker > svg {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  color: var(--primary-color);
}
.site-notice-text {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  overflow: hidden;
}
.site-notice-text strong,
.site-notice-text span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.site-notice-text strong {
  flex: 0 1 auto;
  max-width: 35%;
  font-size: 13px;
}
.site-notice-text span {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
}
.site-notice-controls {
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.site-notice-controls .icon-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
}
.site-notice-controls .icon-btn svg {
  width: 16px;
  height: 16px;
}
.site-notice-ticker[data-count='1'] .site-notice-controls {
  display: none;
}
.site-notice-counter {
  min-width: 32px;
  text-align: center;
  font-size: 12px;
}
.site-announcement-dialog {
  width: min(600px, calc(100vw - 32px));
}
.site-announcement-dialog h2 {
  font-size: 20px;
  overflow-wrap: anywhere;
}
.site-message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
}
.site-announcement-dialog .dialog-actions {
  position: sticky;
  bottom: 0;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  background: var(--surface);
  flex-wrap: wrap;
}
.maintenance-page {
  min-height: 100dvh;
  overflow: auto;
}
.maintenance-main {
  width: min(680px, calc(100% - 40px));
  margin: 12vh auto 40px;
}
.maintenance-main h1 {
  font-size: 28px;
  overflow-wrap: anywhere;
}
.maintenance-main .dialog-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .site-notice-ticker {
    gap: 6px;
    padding-inline: 8px;
  }
  .site-notice-text strong,
  .site-notice-counter {
    display: none;
  }
}
