:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #111827;
  --text: #263241;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #d6dde7;
  --line-soft: #e7ebf0;
  --teal: #0f766e;
  --teal-soft: #dff5f1;
  --blue: #1d4ed8;
  --blue-soft: #e7f0ff;
  --red: #b42318;
  --red-soft: #fee4e2;
  --amber: #b45309;
  --amber-soft: #fef0c7;
  --green: #067647;
  --green-soft: #dcfae6;
  --shadow: 0 14px 34px rgba(15, 23, 42, .08);
  --w: 1440px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fafc 0, #eef1f4 280px),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
  font-size: 15px;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(var(--w), calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.masthead {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.brand-card,
.command-card,
.market-card,
.rail,
.panel,
.story {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.brand-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 132px;
}

.brand-kicker {
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

h1 {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0;
}

.brand-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.command-card {
  padding: 14px;
  min-height: 132px;
  display: grid;
  gap: 12px;
  align-content: center;
}

.searchline {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 150px auto auto;
  gap: 8px;
}

.input,
.select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 0 12px;
}

.input:focus,
.select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  white-space: nowrap;
}

.btn.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.modebar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.refreshline {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.refreshline .btn {
  min-height: 34px;
}

.refresh-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
}

.mode.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: #075e57;
  font-weight: 700;
}

.market-card {
  padding: 14px;
  min-height: 132px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quote {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.quote-name {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.quote-price {
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.quote-sub {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.up {
  color: var(--green);
}

.down {
  color: var(--red);
}

.flat {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.rail,
.panel {
  padding: 14px;
  position: sticky;
  top: 14px;
}

.section-title {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
}

.nav-list,
.source-list,
.stats {
  display: grid;
  gap: 6px;
}

.sync-box {
  display: grid;
  gap: 8px;
}

.sync-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sync-code {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 0 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.sync-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nav-item,
.source-item,
.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  text-align: left;
}

.nav-item {
  width: 100%;
}

.nav-item.active,
.source-item.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: #075e57;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  padding: 0 7px;
}

.nav-item.active .badge,
.source-item.active .badge {
  background: #fff;
  color: var(--teal);
}

.content {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.story {
  min-width: 0;
  padding: 16px;
  box-shadow: 0 1px 5px rgba(15, 23, 42, .06);
  transition: border-color .15s, transform .15s;
}

.story:hover {
  border-color: #aeb8c7;
}

.story.read {
  opacity: .62;
}

.story-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: start;
}

.headline {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.46;
  letter-spacing: 0;
}

.description {
  margin: 10px 0 0;
  color: #425466;
  font-size: 14px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0 8px;
  font-weight: 700;
  font-size: 12px;
}

.source {
  color: #344054;
  font-weight: 700;
}

.star {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--amber);
  font-size: 18px;
  line-height: 1;
}

.star.active {
  border-color: #f6c344;
  background: var(--amber-soft);
}

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

.feed-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  padding: 4px 2px;
}

.feed-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}

.feed-header span {
  color: var(--muted);
  font-size: 12px;
}

.stat {
  min-height: 38px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 0;
}

.stat:last-child {
  border-bottom: 0;
}

.stat strong {
  color: var(--ink);
  font-size: 18px;
}

.source-list {
  margin-top: 16px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.empty,
.error {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 20px;
}

.error {
  color: var(--red);
  background: var(--red-soft);
  border-color: #fda29b;
}

@media (max-width: 1180px) {

  .masthead,
  .workspace {
    grid-template-columns: 1fr;
  }

  .rail,
  .panel {
    position: static;
  }

  .rail {
    order: -1;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .source-list {
    margin-top: 0;
    max-height: 260px;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 18px, var(--w));
    padding-top: 9px;
  }

  .masthead,
  .workspace,
  .market-card,
  .panel {
    grid-template-columns: 1fr;
  }

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

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 28px;
  }
}
