.app {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(260px, 260px) minmax(0, 1fr);
  grid-template-rows: minmax(100vh, auto);
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: stretch;
}

#appSidebar {
  box-sizing: border-box;
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  align-self: stretch;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-deep) 100%);
  z-index: 40;
}

.sidebar {
  flex: 1 1 auto;
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-deep) 100%);
  color: var(--sidebar-text-strong);
  padding: 22px 14px 18px;
  overflow: hidden;
}

.sidebar nav {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 200px);
  overflow: hidden;
}

.sidebar-nav-menu {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar-nav-menu::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.sidebar-top {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

.sidebar-top .brand {
  margin-bottom: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--color-text-on-primary);
  line-height: 1.1;
}

.sidebar-logout-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-on-primary);
  cursor: pointer;
  font: inherit;
  transition: background 0.15s ease;
}

.sidebar-logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-logout-btn .nav-item-icon {
  opacity: 1;
}

.sidebar-logout-label {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.brand {
  flex-shrink: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 18px;
  color: var(--color-text-on-primary);
}

.profile-box {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.profile-box img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.profile-greeting {
  margin: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--sidebar-text);
}

.profile-greeting-line {
  display: block;
  white-space: nowrap;
}

.sidebar .sidebar-user-name,
.profile-greeting .sidebar-user-name,
.profile-greeting #sidebarRoleText {
  display: block;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--color-text-on-primary);
  font-weight: 700;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

.content {
  padding: 18px;
  background: var(--color-bg-page);
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gradient-brand);
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 18px;
  box-shadow: 0 4px 14px rgba(74, 111, 227, 0.22);
  color: var(--color-text-on-primary);
}

.topbar input {
  width: min(360px, 80%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-text-on-primary);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#topbarRoleText {
  color: var(--color-text-on-primary);
  font-size: 1.28rem;
  font-weight: 700;
}

.topbar-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-text-on-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-menu-btn svg {
  width: 22px;
  height: 22px;
}

.topbar-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-text-on-primary);
  cursor: pointer;
}

.topbar-bell svg {
  width: 20px;
  height: 20px;
}

.topbar-bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-error);
  color: var(--color-text-on-primary);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-backdrop);
  z-index: 35;
}

body.sidebar-open .sidebar-backdrop {
  display: block;
}

.fm-lang-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.fm-lang-flag-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.fm-lang-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.fm-lang-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.fm-lang-btn.is-active {
  border-color: var(--color-text-on-primary);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.28);
}

.fm-lang-btn:focus-visible {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 2px;
}

.fm-lang-flag {
  width: 26px;
  height: auto;
  max-height: 18px;
  display: block;
  pointer-events: none;
}

.fm-furigana-wrap {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-on-primary);
  cursor: pointer;
  user-select: none;
}

.fm-furigana-wrap .fm-furigana-input {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary-light);
  cursor: pointer;
}

.fm-furigana-label {
  white-space: nowrap;
}

html[data-fm-furigana="0"] ruby rt {
  display: none;
}

.panel {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 2px 8px rgba(74, 111, 227, 0.06);
}

.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (min-width: 961px) {
  body.sidebar-collapsed .app {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  body.sidebar-collapsed #appSidebar {
    width: 0;
    min-width: 0;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  #appSidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 8px 0 24px rgba(26, 45, 122, 0.25);
  }

  body.sidebar-open #appSidebar {
    transform: translateX(0);
  }
}

@media (max-width: 640px) {
  .content {
    padding: 12px;
  }
}
