/* 台灣企業百科 — 黑白簡潔 */
:root {
  --bg: #fff;
  --ink: #111;
  --muted: #555;
  --line: #ccc;
  --line-light: #e5e5e5;
  --link: #0645ad;
  --link-visited: #0b0080;
  --danger: #a00;
  --sidebar-bg: #f7f7f7;
  --soft: #f5f5f5;
  --font: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Helvetica Neue",
    Arial, sans-serif;
  --max: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:visited {
  color: var(--link-visited);
}

a:hover {
  text-decoration: underline;
}

a.redlink {
  color: var(--danger);
}

img {
  max-width: 100%;
  height: auto;
}

/* Header */
.wiki-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.wiki-header-inner {
  width: 100%;
  margin: 0;
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.wiki-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  color: inherit;
  text-decoration: none;
}

.wiki-wordmark:hover {
  text-decoration: none;
}

.wiki-wordmark-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #000;
}

.wiki-wordmark-tagline {
  font-size: 0.7rem;
  color: var(--muted);
}

.wiki-search {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
  flex: 1;
  max-width: 36rem;
  min-width: 14rem;
}

.wiki-search input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  font: inherit;
  color: var(--ink);
}

.wiki-search input:focus {
  outline: 1px solid #111;
  border-color: #111;
}

.wiki-search button,
.btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid #111;
  border-radius: 0;
  background: #111;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.wiki-search button:hover,
.btn:hover {
  background: #333;
}

.btn-ghost {
  background: #fff;
  color: #111;
}

.btn-danger {
  background: #a00;
  border-color: #a00;
  color: #fff;
}

/* Layout */
.wiki-shell {
  width: 100%;
  margin: 0;
  padding: 0.75rem 1.25rem 2rem;
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr) 15rem;
  gap: 1.25rem;
  align-items: start;
}

.wiki-sidebar {
  padding: 0.5rem 0.25rem 1rem 0;
  font-size: 0.85rem;
  border-right: 1px solid var(--line-light);
}

.wiki-sidebar h3 {
  margin: 1rem 0 0.3rem;
  padding-bottom: 0.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line-light);
}

.wiki-sidebar h3:first-child {
  margin-top: 0.25rem;
}

.wiki-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wiki-sidebar li {
  margin: 0.2rem 0;
  line-height: 1.4;
}

.wiki-main {
  background: #fff;
  border: none;
  padding: 0.25rem 0.5rem 1.5rem;
  min-width: 0;
}

.wiki-rail {
  position: sticky;
  top: 0.5rem;
  padding: 0.35rem 0 1rem 0.85rem;
  font-size: 0.85rem;
  border-left: 1px solid var(--line-light);
}

.wiki-rail h3 {
  margin: 0.9rem 0 0.3rem;
  padding-bottom: 0.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line-light);
}

.wiki-rail h3:first-child {
  margin-top: 0.25rem;
}

.wiki-rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wiki-rail li {
  margin: 0.22rem 0;
  line-height: 1.4;
}

.wiki-rail .ip-log {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.wiki-rail .ip-log li {
  margin: 0.35rem 0;
}

.wiki-page-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}

.wiki-page-tabs a {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--link);
}

.wiki-page-tabs a.selected {
  background: #fff;
  border-color: var(--line);
  border-bottom-color: #fff;
  color: #111;
  font-weight: 700;
}

.wiki-site-sub,
#siteSub {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.firstHeading {
  margin: 0 0 0.4rem;
  padding-bottom: 0.2rem;
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.3;
  border-bottom: 1px solid var(--line);
}

.mw-body-content p {
  margin: 0.55em 0 0.85em;
}

.mw-body-content h2 {
  margin: 1.4rem 0 0.45rem;
  padding-bottom: 0.15rem;
  font-size: 1.25rem;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  clear: both;
}

.mw-body-content h3 {
  margin: 1rem 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.mw-body-content ul,
.mw-body-content ol {
  margin: 0.35em 0 0.85em 1.4em;
  padding: 0;
}

.note {
  font-size: 0.88rem;
  color: var(--muted);
}

blockquote.wiki-quote {
  margin: 0.8em 0;
  padding: 0.4rem 0 0.4rem 0.85rem;
  border-left: 3px solid #111;
  color: var(--ink);
}

/* TOC / index */
#toc,
.toc,
.alpha-index {
  display: table;
  width: auto;
  max-width: 100%;
  padding: 0.65rem 0.85rem;
  margin: 0.9rem 0 1.1rem;
  background: var(--soft);
  border: 1px solid var(--line);
}

.toc .toctitle,
.alpha-index-title {
  text-align: center;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 1;
}

.toc > ul > li {
  margin: 0.12em 0;
}

.tocnumber {
  color: var(--muted);
  margin-right: 0.3em;
}

.alpha-index {
  display: block;
  width: 100%;
}

.alpha-index-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.alpha-index-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.15rem;
  padding: 0.12rem 0.35rem;
  border: 1px solid transparent;
  line-height: 1.3;
}

.alpha-index-link:hover {
  border-color: var(--line);
  background: #eee;
  text-decoration: none;
}

.alpha-count {
  font-size: 0.72em;
  color: var(--muted);
}

/* Infobox */
.infobox {
  float: right;
  clear: right;
  width: 20rem;
  max-width: 100%;
  margin: 0 0 1rem 1rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  background: var(--soft);
  font-size: 0.88rem;
  line-height: 1.5;
  border-spacing: 2px;
  border-collapse: separate;
}

.infobox caption,
.infobox .infobox-title {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  padding: 0.4rem;
  background: #eaeaea;
}

.infobox th,
.infobox td {
  vertical-align: top;
  padding: 0.25rem 0.4rem;
}

.infobox th {
  text-align: left;
  font-weight: 400;
  width: 38%;
  color: #333;
}

.infobox .infobox-image {
  text-align: center;
  padding: 0.5rem;
  background: #fff;
}

.infobox .infobox-caption {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  padding: 0.15rem 0.4rem 0.45rem;
}

/* Tables */
.wikitable {
  margin: 0.9em 0;
  border: 1px solid var(--line);
  border-collapse: collapse;
  background: #fff;
  font-size: 0.92rem;
  width: 100%;
}

.wikitable th,
.wikitable td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  vertical-align: top;
}

.wikitable th {
  background: #eee;
  text-align: left;
  font-weight: 700;
}

.wikitable caption {
  caption-side: top;
  text-align: left;
  font-weight: 700;
  padding: 0.25em 0;
}

.catlinks {
  clear: both;
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 0.4rem 0.7rem;
  margin-top: 1.4rem;
  font-size: 0.85rem;
}

.catlinks ul {
  display: inline;
  margin: 0;
  padding: 0;
  list-style: none;
}

.catlinks li {
  display: inline;
}

.catlinks li + li::before {
  content: " | ";
  color: var(--muted);
}

.wiki-footer {
  clear: both;
  margin-top: 1.5rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line-light);
  font-size: 0.78rem;
  color: var(--muted);
}

.wiki-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
}

.edit-banner {
  display: none;
  margin: 0 0 0.75rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--soft);
  font-size: 0.85rem;
}

.edit-banner.is-visible {
  display: block;
}

/* Portal home */
.portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 0.9rem 0 1.25rem;
}

.portal-box {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.7rem 0.85rem 0.85rem;
  min-width: 0;
}

.portal-box h2 {
  margin: 0 0 0.4rem;
  padding-bottom: 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.portal-box-wide {
  grid-column: 1 / -1;
}

.portal-search-hint {
  margin: 0.65rem 0 0.9rem;
  padding: 0.55rem 0.7rem;
  background: var(--soft);
  border: 1px solid var(--line);
}

.portal-search-hint p {
  margin: 0;
}

.portal-stats,
.portal-featured,
.portal-industries {
  margin: 0.25rem 0 0.4rem 1.15rem;
  padding: 0;
}

.portal-featured,
.portal-industries {
  columns: 2;
  column-gap: 1.25rem;
}

.portal-industries li,
.portal-featured li {
  break-inside: avoid;
  margin-bottom: 0.2rem;
}

.corp-list {
  columns: 2;
  column-gap: 1.25rem;
  margin-left: 0;
  padding-left: 1.15rem;
}

.corp-list li {
  break-inside: avoid;
}

.letter-section {
  scroll-margin-top: 0.75rem;
}

/* Editor */
.editor-shell {
  width: 100%;
  margin: 0;
  padding: 1.25rem 1.25rem 2.5rem;
}

.editor-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 1rem 1.1rem;
}

.editor-card label {
  display: block;
  font-weight: 700;
  margin: 0.75rem 0 0.3rem;
}

.editor-card input,
.editor-card textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0;
  font: inherit;
  background: #fff;
}

.editor-card textarea {
  min-height: 9rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.45;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.editor-status {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .wiki-shell {
    grid-template-columns: 12rem minmax(0, 1fr);
  }

  .wiki-rail {
    display: none;
  }
}

@media (max-width: 860px) {
  .wiki-shell {
    grid-template-columns: 1fr;
  }

  .wiki-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line-light);
    padding-bottom: 0.75rem;
  }

  .infobox {
    float: none;
    width: 100%;
    margin: 0 0 1rem;
  }

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

  .portal-featured,
  .portal-industries,
  .corp-list {
    columns: 1;
  }

  .wiki-search {
    margin-left: 0;
    max-width: none;
    width: 100%;
  }
}

@media print {
  .wiki-header,
  .wiki-sidebar,
  .wiki-rail,
  .wiki-page-tabs,
  .wiki-search,
  .edit-banner {
    display: none !important;
  }

  .wiki-shell {
    display: block;
    padding: 0;
  }

  .wiki-main {
    padding: 0;
  }
}
