:root {
  color-scheme: light;
  --background: #ffffff;
  --text: #333333;
  --ink: #000000;
  --muted: #666666;
  --line: #e0e0e0;
  --soft: #f5f5f5;
}

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.site-header {
  border-bottom: 1px solid var(--line);
  padding: 16px 32px;
}

.topbar {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 32px;
}

.home-link {
  color: var(--ink);
  font-weight: 700;
}

.nav-link {
  color: var(--text);
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--muted);
}

.language-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--background);
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
  transition: background-color 0.2s, color 0.2s;
}

.lang-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--background);
}

.layout {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 180px minmax(0, 720px) 260px;
  gap: 48px;
  padding: 64px 16px;
}

.main-nav,
.sidebar {
  position: sticky;
  top: 32px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow: auto;
}

.sidebar-label {
  display: block;
  margin-bottom: 16px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 700;
}

.sections {
  display: grid;
  gap: 10px;
}

.section-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 0;
  text-align: left;
  font-size: 14px;
  line-height: 1.45;
  transition: color 0.2s;
}

.section-button:hover,
.section-button.active {
  color: var(--ink);
}

.search-wrap {
  display: grid;
  gap: 8px;
}

#search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--background);
  color: var(--text);
  padding: 10px 12px;
}

.result-count {
  color: var(--muted);
  font-size: 13px;
}

.page-list {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

.page-item {
  width: 100%;
  display: grid;
  gap: 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  padding: 0 0 16px;
  text-align: left;
}

.page-item-title {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.25;
  transition: color 0.2s;
}

.page-item:hover .page-item-title,
.page-item.active .page-item-title {
  color: var(--muted);
}

.page-item-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.reader {
  min-width: 0;
}

.reader-head {
  max-width: 720px;
  margin: 0 auto 32px;
}

.reader-section {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

#page-title {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 48px;
  line-height: 1.2;
  margin-bottom: 24px;
}

.reader-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.translation-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.translation-note:empty {
  display: none;
}

.article {
  max-width: 720px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  transition: opacity 150ms ease, transform 150ms ease;
}

.article.switching {
  opacity: 0;
  transform: translateY(4px);
}

.article h1,
.article h2,
.article h3,
.article h4 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.2;
}

.article h1 {
  font-size: 40px;
  margin: 0 0 32px;
}

.article h2 {
  font-size: 32px;
  margin: 64px 0 16px;
}

.article h3 {
  font-size: 24px;
  margin: 32px 0 16px;
}

.article h4 {
  font-size: 20px;
  margin: 24px 0 12px;
}

.article p {
  margin-bottom: 16px;
}

.article blockquote {
  border-left: 4px solid var(--line);
  color: var(--muted);
  font-style: italic;
  margin: 32px 0;
  padding-left: 32px;
}

.article a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0 0 24px;
}

.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
  line-height: 1.6;
}

.article td,
.article th {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
}

.article ul,
.article ol {
  margin: 0 0 16px 22px;
}

.align-center {
  text-align: center;
}

.missing-image {
  display: inline-block;
  margin: 8px 0 16px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

.reader-actions {
  max-width: 720px;
  margin: 64px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  border-top: 1px solid var(--line);
  padding-top: 32px;
}

.reader-actions button {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-size: 14px;
  line-height: 1.45;
  transition: color 0.2s;
}

.reader-actions button:last-child {
  text-align: right;
}

.reader-actions button:hover {
  color: var(--muted);
}

.reader-actions button:disabled {
  color: var(--line);
  cursor: not-allowed;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 32px;
  }

  .main-nav {
    grid-column: 1 / -1;
    position: relative;
    top: 0;
    max-height: none;
  }

  .sections {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .section-button {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (max-width: 820px) {
  .site-header {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px 24px;
  }

  .language-toggle {
    width: 100%;
    margin-left: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 40px 16px;
  }

  .sidebar {
    position: relative;
    top: 0;
    max-height: none;
    order: -1;
  }

  .page-list {
    max-height: 280px;
    overflow: auto;
  }

  #page-title {
    font-size: 36px;
  }
}

/* KON'S TONE / XOOPS inspired skin */
:root {
  --background: #ffffff;
  --text: #666666;
  --ink: #333333;
  --muted: #888888;
  --line: #cacaca;
  --soft: #f5f5f5;
  --accent: #ff0099;
  --battle-brown: #704e3c;
  --battle-blue: #588cbf;
}

html,
body {
  background: #000000;
}

body {
  color: var(--text);
  font-family: Verdana, Helvetica, Arial, "Hiragino Kaku Gothic Pro", "Meiryo", sans-serif;
  font-size: 12px;
  line-height: 1.3;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.site-frame {
  width: 960px;
  max-width: calc(100vw - 80px);
  margin: 40px auto;
  background: #ffffff;
  color: var(--text);
}

.site-header {
  border: 0;
  padding: 0;
}

.topbar {
  max-width: none;
  min-height: 24px;
  margin: 0;
  padding: 3px 10px 0;
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--text);
  font-size: 10px;
  line-height: 1.4;
}

.site-context,
.home-link,
.nav-link {
  color: var(--text);
  font-weight: 400;
}

.site-context {
  margin-right: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.home-link::after,
.nav-link::after {
  content: "|";
  display: inline-block;
  margin: 0 6px;
  color: var(--text);
}

.brand-panel {
  height: 160px;
  border-top: 1px dashed #000000;
  border-bottom: 1px dashed #000000;
  display: block;
  padding: 0;
  background: url("../theme/kons7/images/konsType01.gif") no-repeat left top;
}

.brand-logo {
  display: block;
  height: 120px;
  overflow: hidden;
}

.brand-logo:hover {
  text-decoration: none;
}

.brand-logo img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 0;
}

.brand-ear {
  height: 40px;
  border-bottom: 1px dashed #000000;
  background: url("../theme/kons7/images/ear01_b.gif") no-repeat right bottom;
}

.language-toggle {
  margin-left: auto;
  gap: 0;
}

.language-select {
  display: block;
  width: auto;
  height: auto;
  margin-right: 4px;
}

.lang-button {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.lang-button img {
  display: block;
  width: auto;
  height: auto;
}

.lang-button .lang-on {
  display: none;
}

.lang-button.active .lang-off,
.lang-button:hover .lang-off {
  display: none;
}

.lang-button.active .lang-on,
.lang-button:hover .lang-on {
  display: block;
}

.layout {
  width: 100%;
  max-width: none;
  margin: 0;
  display: grid;
  grid-template-columns: 19% 62% 19%;
  gap: 0;
  padding: 0 0 15px;
}

.main-nav,
.sidebar {
  position: relative;
  top: auto;
  grid-column: auto;
  order: initial;
  max-height: none;
  overflow: visible;
  align-self: start;
  color: var(--text);
  font-size: 10px;
  letter-spacing: 1px;
  line-height: 1.4;
}

.main-nav {
  padding: 20px 0 0 10px;
}

.sidebar {
  padding: 20px 0 0;
}

.sidebar-label {
  margin: 3px 0 6px;
  padding: 0 10px;
  color: #000000;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

.sections {
  display: grid;
  gap: 0;
  padding: 0 0 0 10px;
}

.section-button {
  width: 100%;
  margin: 0 0 4px;
  padding: 3px 10px;
  color: var(--text);
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 1px;
}

.section-button:hover,
.section-button.active {
  color: var(--accent);
}

.search-wrap {
  padding: 0 10px;
  gap: 6px;
}

#search {
  height: 22px;
  border: 1px solid #cccccc;
  border-radius: 0;
  color: var(--text);
  padding: 1px 4px;
  font-size: 11px;
}

.result-count {
  color: var(--text);
  font-size: 10px;
  line-height: 1.4;
}

.anniversary-card {
  margin: 0 0 14px;
  padding: 0 10px;
}

.anniversary-card .sidebar-label {
  padding-left: 0;
  padding-right: 0;
}

.anniversary-next {
  margin: 0 0 8px;
  border-bottom: 1px dotted #cccccc;
  padding: 0 0 8px;
}

.anniversary-kicker,
.anniversary-note,
.anniversary-days {
  display: block;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.anniversary-title {
  display: block;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

.anniversary-date {
  display: block;
  color: var(--text);
  font-size: 10px;
  line-height: 1.4;
}

.anniversary-list {
  display: grid;
  gap: 4px;
}

.anniversary-item {
  border: 0;
  border-bottom: 1px dotted #cccccc;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0 0 5px;
  text-align: left;
}

.anniversary-item:hover .anniversary-title,
.anniversary-item.active .anniversary-title {
  color: var(--accent);
}

.page-list {
  margin-top: 10px;
  padding: 0 10px;
  display: grid;
  gap: 0;
}

.page-item {
  margin: 0;
  border: 0;
  border-bottom: 1px dotted #cccccc;
  padding: 3px 0 5px;
}

.page-item-title {
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  line-height: 1.4;
}

.page-item:hover .page-item-title,
.page-item.active .page-item-title {
  color: var(--accent);
}

.page-item-meta {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.reader {
  min-width: 0;
  padding: 20px 30px 0;
  color: #333333;
  font-size: 13px;
  letter-spacing: 1px;
  line-height: 1.9;
}

.reader-head {
  max-width: none;
  margin: 0 0 18px;
}

.reader-section,
.reader-meta,
.translation-note {
  color: var(--text);
  font-size: 10px;
  line-height: 1.5;
}

.source-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--text);
  font-size: 10px;
  line-height: 1.5;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.source-link[hidden] {
  display: none;
}

.reader-section {
  margin-bottom: 4px;
}

#page-title {
  margin: 0 0 10px;
  color: var(--battle-brown);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.article {
  max-width: none;
  margin: 0;
  color: #333333;
  font-size: 13px;
  line-height: 1.9;
  letter-spacing: 1px;
}

.article p,
.article li,
.article td {
  color: #333333;
  font-size: 13px;
  line-height: 1.9;
}

.article p {
  margin: 0 0 18px;
}

.article h1,
.article h2,
.article h3,
.article h4 {
  margin: 10px 0 5px;
  color: var(--battle-brown);
  font-family: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.article h1 {
  font-size: 22px;
}

.article h1 + h1,
.article h2 {
  color: var(--battle-blue);
}

.article h2 {
  font-size: 18px;
}

.article h3,
.article h4 {
  font-size: 13px;
  text-align: left;
}

.article blockquote {
  margin: 12px 0;
  border-left: 0;
  background: var(--soft);
  color: var(--text);
  padding: 6px;
}

.article hr {
  height: 1px;
  margin: 16px 0;
  border: 0;
  border-top: 1px dotted #cccccc;
}

.article img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 16px auto;
  border-radius: 0;
}

.article table {
  width: 100%;
  border-collapse: collapse;
}

.article th,
.article td {
  border-bottom: 1px solid #cacaca;
  padding: 2px;
  vertical-align: top;
}

.missing-image {
  color: var(--muted);
  font-style: italic;
}

.reader-actions {
  max-width: none;
  margin: 28px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px dotted #cccccc;
  padding-top: 12px;
}

.reader-actions button {
  color: var(--text);
  font-size: 10px;
  line-height: 1.4;
}

.reader-actions button:hover {
  color: var(--accent);
}

.reader-actions button:disabled {
  color: #cccccc;
}

.site-footer {
  min-height: 30px;
  border-top: 1px dashed #000000;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 0 0 10px;
  color: var(--text);
  font-size: 9px;
  line-height: 1.4;
}

.footer-ear {
  display: block;
  width: auto;
  height: auto;
  margin-left: 0;
}

@media (max-width: 1040px) {
  .site-frame {
    max-width: none;
    width: calc(100vw - 32px);
    margin: 16px auto;
  }

  .layout {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .main-nav {
    grid-column: auto;
  }

  .sidebar {
    grid-column: 1 / -1;
    order: initial;
    padding: 0 30px 20px 190px;
  }

  .page-list {
    max-height: 220px;
    overflow: auto;
  }
}

@media (max-width: 720px) {
  .site-frame {
    width: 100%;
    margin: 0;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 4px 0;
    padding-bottom: 6px;
  }

  .language-toggle {
    width: 100%;
    margin-left: 0;
  }

  .brand-panel {
    height: 112px;
    background-size: auto 84px;
  }

  .brand-logo {
    height: 84px;
  }

  .brand-logo img {
    max-height: 84px;
  }

  .brand-ear {
    height: 28px;
    background-size: auto 28px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .main-nav,
  .sidebar,
  .reader {
    padding: 18px 16px 0;
  }

  .sections,
  .page-list,
  .search-wrap,
  .anniversary-card,
  .sidebar-label {
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar {
    grid-column: auto;
    order: initial;
  }

  .page-list {
    max-height: 280px;
    overflow: auto;
  }

  #page-title {
    font-size: 14px;
  }

  .article,
  .article p,
  .article li,
  .article td {
    font-size: 12px;
  }

  .site-footer {
    justify-content: flex-start;
    flex-wrap: wrap;
    padding: 8px 0 0 8px;
  }
}
