:root {
  --futsuken-fixed-topbar-height: 56px;
  --futsuken-fixed-bottom-height: 76px;
  --futsuken-fixed-inline-x: 12px;
  --futsuken-fixed-inline-y: 8px;
  --futsuken-fixed-icon-size: 28px;
  --futsuken-fixed-gap: 8px;
  --futsuken-fixed-tab-gap: 6px;
  --futsuken-fixed-tab-height: 30px;
  --futsuken-fixed-tab-radius: 999px;
  --futsuken-fixed-bottom-radius: 0;
  --futsuken-surface-page: #eee5d2;
  --futsuken-surface-main: #fffaf1;
  --futsuken-surface-subtle: rgba(36, 106, 71, 0.07);
  --futsuken-text-main: #21422f;
  --futsuken-text-muted: #627064;
  --futsuken-green-main: #246a47;
  --futsuken-active-bg: #ffffff;
  --futsuken-disabled-bg: rgba(255, 255, 255, 0.50);
  --futsuken-disabled-text: rgba(87, 98, 92, 0.55);
  --futsuken-line: rgba(36, 106, 71, 0.16);
  --futsuken-radius: 12px;
  --futsuken-radius-small: 8px;
}

body.futsuken-fixed-ui-page .futsuken-home,
body.futsuken-fixed-ui-page .reference-reader {
  padding-top: calc(var(--futsuken-fixed-topbar-height) + 12px) !important;
  padding-bottom: calc(var(--futsuken-fixed-bottom-height) + 12px + env(safe-area-inset-bottom)) !important;
}

body.futsuken-fixed-ui-page .reference-reader {
  margin-top: 0 !important;
  --reader-topbar-height: var(--futsuken-fixed-topbar-height);
  --reader-bottom-bar-height: var(--futsuken-fixed-bottom-height);
  --reader-content-top-space: calc(var(--futsuken-fixed-topbar-height) + 12px);
  --reader-content-bottom-space: calc(var(--futsuken-fixed-bottom-height) + 12px);
}

body.futsuken-fixed-ui-page .reference-reader__chapter,
body.futsuken-fixed-ui-page .reference-reader__lesson {
  scroll-margin-top: calc(var(--futsuken-fixed-topbar-height) + 8px) !important;
  scroll-margin-bottom: calc(var(--futsuken-fixed-bottom-height) + 16px) !important;
}

.futsuken-fixed-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
  width: 100%;
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--futsuken-line);
  background: #f7f1e6;
  box-shadow: none;
}

.futsuken-fixed-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--futsuken-fixed-gap);
  width: 100%;
  min-height: var(--futsuken-fixed-topbar-height);
  padding: var(--futsuken-fixed-inline-y) var(--futsuken-fixed-inline-x);
  box-sizing: border-box;
}

.futsuken-fixed-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--futsuken-text-main);
  text-decoration: none;
  font-weight: 800;
  flex: 0 0 auto;
}

.futsuken-fixed-topbar__brand-icon,
.futsuken-app-icon {
  display: block;
  width: var(--futsuken-fixed-icon-size);
  height: var(--futsuken-fixed-icon-size);
  border-radius: 8px;
  flex: 0 0 auto;
}

.futsuken-fixed-topbar__brand-copy {
  display: grid;
  min-width: 0;
}

.futsuken-fixed-topbar__brand-copy strong {
  font-size: 0.92rem;
  line-height: 1.08;
  letter-spacing: 0.01em;
}

.futsuken-fixed-topbar__brand-copy span {
  font-size: 0.72rem;
  line-height: 1.08;
  color: var(--futsuken-text-muted);
}

.futsuken-fixed-topbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--futsuken-fixed-gap);
  min-width: 0;
  flex: 1 1 auto;
}

.futsuken-fixed-topbar__search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--futsuken-fixed-tab-height);
  padding: 0 0.82rem;
  border: 1px solid var(--futsuken-line);
  border-radius: var(--futsuken-fixed-tab-radius);
  background: var(--futsuken-surface-main);
  color: var(--futsuken-text-main);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.futsuken-fixed-topbar__search.is-disabled {
  cursor: default;
  opacity: 1;
}

.futsuken-fixed-topbar__grade-tabs {
  display: flex;
  align-items: center;
  gap: var(--futsuken-fixed-tab-gap);
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.futsuken-fixed-topbar__grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--futsuken-fixed-tab-height);
  padding: 0 0.66rem;
  border-radius: var(--futsuken-fixed-tab-radius);
  border: 1px solid transparent;
  background: transparent;
  color: #57625c;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.futsuken-fixed-topbar__grade.is-active {
  background: var(--futsuken-active-bg);
  border-color: var(--futsuken-line);
  color: var(--futsuken-text-main);
}

.futsuken-fixed-topbar__grade--disabled {
  background: var(--futsuken-disabled-bg);
  color: var(--futsuken-disabled-text);
}

.futsuken-bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  width: min(calc(100% - 16px), 720px);
  margin: 0 auto;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  border: 1px solid var(--futsuken-line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: #f7f1e6;
  box-shadow: 0 -8px 24px rgba(35, 44, 60, 0.06);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  box-sizing: border-box;
  transform: none;
}

.futsuken-bottom-tabs__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 48px;
  padding: 0.25rem 0.15rem;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #5d6a63;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  box-sizing: border-box;
}

.futsuken-bottom-tabs__item:not(.futsuken-bottom-tabs__item--disabled):hover {
  color: var(--futsuken-green-main);
  background: rgba(255, 255, 255, 0.48);
}

.futsuken-bottom-tabs__item:focus-visible {
  outline: 3px solid rgba(36, 106, 71, 0.32);
  outline-offset: 1px;
}

.futsuken-ui-icon {
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.futsuken-bottom-tabs__label {
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
}

.futsuken-bottom-tabs__item--active {
  background: var(--futsuken-active-bg);
  border-color: var(--futsuken-line);
  color: var(--futsuken-green-main);
  box-shadow: 0 3px 10px rgba(35, 44, 60, 0.08);
}

.futsuken-bottom-tabs__item--disabled {
  color: var(--futsuken-disabled-text);
  cursor: default;
}

.futsuken-bottom-tabs__badge {
  position: absolute;
  top: 1px;
  right: 1px;
  padding: 0.12rem 0.28rem;
  border: 1px solid rgba(87, 98, 92, 0.12);
  border-radius: 999px;
  background: #f0eee8;
  color: rgba(87, 98, 92, 0.66);
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1;
}

@media (min-width: 900px) {
  .futsuken-fixed-topbar__brand-copy strong {
    font-size: 0.96rem;
  }

  .futsuken-fixed-topbar__brand-copy span {
    font-size: 0.75rem;
  }

  .futsuken-bottom-tabs {
    bottom: 10px;
    border-bottom: 1px solid var(--futsuken-line);
    border-radius: 16px;
  }
}

@media (max-width: 390px) {
  .futsuken-bottom-tabs {
    width: calc(100% - 8px);
    padding-inline: 4px;
  }

  .futsuken-bottom-tabs__item {
    padding-inline: 0;
  }

  .futsuken-bottom-tabs__badge {
    right: -1px;
    padding-inline: 0.22rem;
  }
}
