/* ============================================================
   株Links — Apple-style design system
   ============================================================ */

:root {
  color-scheme: light dark;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-hover: #e8e8ed;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --accent: #0071e3;
  --accent-tint: rgba(0, 113, 227, 0.1);
  --separator: rgba(0, 0, 0, 0.08);
  --glass: rgba(251, 251, 253, 0.8);
  --field-bg: rgba(0, 0, 0, 0.04);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 980px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-hover: #3a3a3c;
    --text: #f5f5f7;
    --text-2: #86868b;
    --accent: #2997ff;
    --accent-tint: rgba(41, 151, 255, 0.16);
    --separator: rgba(255, 255, 255, 0.14);
    --glass: rgba(22, 22, 23, 0.8);
    --field-bg: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

/* ===== Base ===== */

body {
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro JP', 'Helvetica Neue',
    'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Arial, 'Noto Sans JP', sans-serif;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.body {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

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

a:hover {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.6em;
}

h2 {
  font-size: 1.1em;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.4em 0 0.5em;
}

p {
  margin: 0.8em 0;
}

ul {
  padding: 0 0 0 1.2em;
  margin: 0 0 1.2em;
}

li {
  margin: 4px 0 0;
}

main#main {
  padding: 28px 0 56px;
}

/* ===== Header (frosted glass) ===== */

.siteheader {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}

.siteheader-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}

#site-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.titlelink {
  color: var(--text);
}

.headernav {
  order: 2;
  min-width: 0;
}

.navlist {
  display: flex;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.navlist::-webkit-scrollbar {
  display: none;
}

.navlist li {
  margin: 0;
}

.navlink {
  display: inline-block;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease;
}

.navlink:hover {
  color: var(--text);
  background: var(--field-bg);
}

.navlink i {
  font-size: 12px;
  margin-right: 2px;
}

/* ===== Search field ===== */

.sch {
  order: 3;
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}

.schinp {
  width: 200px;
  padding: 7px 40px 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--field-bg);
  color: var(--text);
  font-size: 14px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.schinp::placeholder {
  color: var(--text-2);
}

.schinp:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.schbtn {
  position: absolute;
  right: 4px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.schbtn:hover {
  filter: brightness(1.1);
}

/* ===== Layout ===== */

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.maintxt,
.kabulinks,
.schlist,
div#side {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.maintxt a,
.schlist a {
  color: var(--accent);
}

.maintxt a:hover,
.schlist a:hover {
  text-decoration: underline;
}

/* ===== Stock hero ===== */

.brand {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  margin: 0 0 20px;
  box-shadow: var(--shadow);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}

.chip-code {
  background: var(--accent-tint);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

h1.symbol {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 14px 0;
}

.brand .chips.meta {
  margin: 0;
}

/* ===== Link tiles ===== */

.linktitle {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
  margin: 26px 0 10px;
}

.kabulinks .linktitle:first-child,
div#side .linktitle:first-child {
  margin-top: 0;
}

.kabulinks ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
}

.kabulinks li {
  margin: 0;
}

.kabulinks a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s ease;
}

.kabulinks a::after {
  content: '↗';
  color: var(--text-2);
  font-size: 12px;
  transition: color 0.2s ease, transform 0.2s ease;
}

.kabulinks a:hover {
  background: var(--surface-hover);
}

.kabulinks a:hover::after {
  color: var(--accent);
  transform: translate(1px, -1px);
}

/* ===== Stock list (sidebar / search results) ===== */

.stocklist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stocklist li {
  margin: 0;
  border-top: 1px solid var(--separator);
}

.stocklist li:first-child {
  border-top: none;
}

.stocklist a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 2px;
  color: var(--text);
  font-size: 14px;
}

.stocklist .s-code {
  flex-shrink: 0;
  min-width: 3.4em;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.stocklist a:hover .s-name {
  color: var(--accent);
}

#sch-empty {
  color: var(--text-2);
}

/* ===== Stock table (全銘柄一覧) ===== */

.stocktable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 8px 0 0;
}

.stocktable td {
  border: none;
  border-top: 1px solid var(--separator);
  padding: 9px 12px;
}

.stocktable tr:hover td {
  background: var(--surface-2);
}

.stocktable td:first-child {
  width: 4.5em;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.stocktable a {
  color: var(--text);
}

.stocktable a:hover {
  color: var(--accent);
}

/* ===== Tags ===== */

a.chip {
  transition: background 0.2s ease, color 0.2s ease;
}

a.chip:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.crumb {
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 10px;
}

.crumb a {
  color: var(--text-2);
}

.crumb a:hover {
  color: var(--accent);
}

.maintxt .tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0 0 6px;
}

.maintxt .tagcloud li {
  margin: 0;
}

.maintxt .tagcloud a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s ease;
}

.maintxt .tagcloud a:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.tagcloud .t-count {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.taglist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.taglist li {
  margin: 0;
  border-top: 1px solid var(--separator);
}

.taglist li:first-child {
  border-top: none;
}

.taglist a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px;
  color: var(--text);
  font-size: 14px;
}

.taglist a:hover .t-label {
  color: var(--accent);
}

.taglist .t-count {
  flex-shrink: 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ===== Search filters ===== */

.schfilters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.schsel {
  appearance: none;
  -webkit-appearance: none;
  max-width: 100%;
  padding: 8px 32px 8px 14px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-pill);
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.schsel:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

#sch-count,
#sch-hint {
  color: var(--text-2);
  font-size: 13px;
}

/* ===== Footer ===== */

footer {
  border-top: 1px solid var(--separator);
  margin: 80px 0 0;
  padding: 32px 20px 48px;
  font-size: 12px;
  color: var(--text-2);
}

.footnav {
  display: flex;
  justify-content: center;
  gap: 24px;
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}

.footnav li {
  margin: 0;
}

.footlink {
  color: var(--text-2);
  transition: color 0.2s ease;
}

.footlink:hover {
  color: var(--text);
}

.foottxt {
  display: flex;
  justify-content: center;
  padding: 0;
}

/* ===== Responsive ===== */

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

@media (max-width: 720px) {
  .headernav {
    order: 3;
    flex-basis: 100%;
  }

  .sch {
    order: 2;
  }

  .schinp {
    width: 150px;
  }

  .maintxt,
  .kabulinks,
  .schlist,
  div#side {
    padding: 22px 18px;
  }

  .brand {
    padding: 26px 18px;
  }
}
