:root {
  --ink: #172033;
  --muted: #697386;
  --line: #e4e8f0;
  --paper: #ffffff;
  --canvas: #f5f7fb;
  --accent: #5b5ce2;
  --accent-soft: #ececfe;
  --warm: #ffbd4a;
  --shadow: 0 14px 36px rgba(31, 40, 67, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(91, 92, 226, .13), transparent 28rem),
    var(--canvas);
  font-family: "Noto Sans JP", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1440px;
  margin: auto;
  padding: 30px 32px 18px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 36px; filter: drop-shadow(0 5px 8px rgba(255, 189, 74, .28)); }
.eyebrow { margin: 0 0 5px; color: var(--accent); font: 700 11px/1 "Plus Jakarta Sans", sans-serif; letter-spacing: .14em; }
h1 { margin: 0; font-size: clamp(20px, 3vw, 29px); letter-spacing: -.04em; }

.update-box {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  color: var(--muted);
  font-size: 12px;
  backdrop-filter: blur(12px);
}

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #2fba73; box-shadow: 0 0 0 4px rgba(47,186,115,.12); }
.icon-button { border: 0; border-radius: 50%; background: #eef0f6; width: 28px; height: 28px; color: var(--ink); }
.icon-button.loading { animation: spin .8s linear infinite; }

main { max-width: 1440px; margin: auto; padding: 0 32px 64px; }

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 142px;
  margin: 10px 0 22px;
  padding: 26px 30px;
  overflow: hidden;
  border-radius: 26px;
  color: white;
  background: linear-gradient(125deg, #34359d 0%, #6062dc 58%, #828cf4 100%);
  box-shadow: 0 18px 50px rgba(65, 67, 166, .20);
  position: relative;
}
.hero::after { content: ""; position: absolute; width: 260px; height: 260px; right: -65px; top: -105px; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; box-shadow: 0 0 0 38px rgba(255,255,255,.05), 0 0 0 78px rgba(255,255,255,.04); }
.date-nav { display: flex; align-items: center; gap: 18px; z-index: 1; }
.date-nav > div { min-width: 175px; text-align: center; }
.date-label { display: block; margin-bottom: 6px; opacity: .65; font-size: 11px; letter-spacing: .15em; }
#currentDate { display: block; font-size: clamp(21px, 3vw, 30px); }
.date-select { width: 100%; height: 31px; margin-top: 9px; padding: 0 30px 0 9px; border: 1px solid rgba(255,255,255,.24); border-radius: 9px; color: white; background: rgba(255,255,255,.11); font-size: 11px; }
.date-select option { color: var(--ink); background: white; }
.nav-button { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.27); border-radius: 14px; color: white; background: rgba(255,255,255,.11); }
.nav-button:disabled { opacity: .28; cursor: default; }
.today-button { height: 38px; padding: 0 14px; border: 1px solid rgba(255,255,255,.42); border-radius: 12px; color: #35379c; background: white; font-size: 12px; font-weight: 700; white-space: nowrap; }
.today-button:disabled { opacity: .45; cursor: default; }
.hero-copy { z-index: 1; text-align: right; }
.hero-copy p { margin: 8px 0 0; opacity: .75; font-size: 13px; }
.count { font: 700 20px "Plus Jakarta Sans", sans-serif; }

.toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 190px 170px; gap: 12px; margin-bottom: 24px; }
.search-box { display: flex; align-items: center; gap: 10px; padding: 0 17px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--muted); }
.search-box input { min-width: 0; width: 100%; height: 46px; border: 0; outline: 0; color: var(--ink); background: transparent; }
select { height: 48px; padding: 0 38px 0 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: white; }

.paper-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.paper-card { overflow: hidden; border: 1px solid rgba(222,226,237,.86); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.paper-card:hover { transform: translateY(-4px); box-shadow: 0 20px 44px rgba(31,40,67,.13); }
.paper-card.read { opacity: .78; }
.card-image-wrap { aspect-ratio: 16/7.7; position: relative; overflow: hidden; background: linear-gradient(135deg, #dfe2ff, #f4eaff); }
.card-image { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.paper-card:hover .card-image { transform: scale(1.025); }
.rank-badge { position: absolute; left: 13px; top: 13px; padding: 6px 10px; border-radius: 999px; color: white; background: rgba(16,22,40,.76); font: 700 11px "Plus Jakarta Sans"; backdrop-filter: blur(8px); }
.save-button { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--ink); background: rgba(255,255,255,.9); font-size: 22px; box-shadow: 0 5px 15px rgba(18,25,46,.14); }
.save-button.saved { color: #d68600; background: #fff4cf; }
.card-body { padding: 19px 20px 18px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 25px; }
.tag { padding: 4px 8px; border-radius: 7px; color: #5153b9; background: var(--accent-soft); font-size: 10px; font-weight: 700; }
.paper-title { margin: 12px 0 6px; font-size: 18px; line-height: 1.55; letter-spacing: -.025em; }
.original-title { margin: 0 0 13px; color: #8a91a1; font: 600 11px/1.5 "Plus Jakarta Sans", sans-serif; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.short-summary { min-height: 5.7em; margin: 0; color: #505a6e; font-size: 13px; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; gap: 16px; margin: 16px 0 14px; color: var(--muted); font-size: 12px; }
.detail-button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 11px 13px; border: 0; border-radius: 11px; color: #4648bd; background: #f0f0ff; font-weight: 700; font-size: 12px; }

.update-notice { position: sticky; top: 12px; z-index: 4; max-width: 420px; margin: 0 auto 18px; padding: 12px 16px; border-radius: 12px; color: white; background: #222b43; box-shadow: var(--shadow); text-align: center; font-size: 13px; }
.update-notice button { margin-left: 8px; border: 0; color: #ffce72; background: transparent; font-weight: 700; }
.empty-state { padding: 90px 20px; text-align: center; color: var(--muted); }
.empty-state span { font-size: 36px; }
.empty-state h2 { color: var(--ink); }

.paper-dialog { width: min(760px, calc(100% - 28px)); max-height: 88vh; padding: 0; border: 0; border-radius: 24px; color: var(--ink); box-shadow: 0 28px 90px rgba(14,20,40,.28); }
.paper-dialog::backdrop { background: rgba(21,28,46,.55); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; float: right; top: 16px; right: 16px; z-index: 2; width: 38px; height: 38px; margin: 16px; border: 0; border-radius: 50%; background: rgba(255,255,255,.9); font-size: 24px; box-shadow: 0 5px 15px rgba(20,28,48,.15); }
.dialog-hero { width: 100%; aspect-ratio: 16/6; object-fit: cover; background: #e8eaff; }
.dialog-body { padding: 26px 34px 36px; }
.dialog-body h2 { margin: 8px 0; font-size: 25px; line-height: 1.5; }
.dialog-original { color: var(--muted); font-size: 13px; }
.source-note { display: inline-block; margin: 12px 0 18px; padding: 6px 10px; border-radius: 8px; background: #fff4d8; color: #805800; font-size: 11px; font-weight: 700; }
.detail-section { margin-top: 22px; }
.detail-section h3 { margin: 0 0 8px; font-size: 14px; }
.detail-section p { margin: 0; color: #505a6e; font-size: 14px; line-height: 1.9; white-space: pre-wrap; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 8px; }
.keyword-list span { padding: 7px 10px; border-radius: 999px; color: #484aa8; background: #eeeeff; font-size: 12px; font-weight: 700; }
.insight-list { display: grid; gap: 9px; margin: 0; padding-left: 20px; color: #505a6e; font-size: 14px; line-height: 1.8; }
.resummary-panel { margin-top: 28px; padding: 20px; border: 1px solid #dfe2ff; border-radius: 17px; background: linear-gradient(145deg, #f8f8ff, #f2f4ff); }
.resummary-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.resummary-heading h3 { margin: 5px 0 14px; font-size: 17px; }
.beta-label, .preview-label { color: #5557c7; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.resummary-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.resummary-panel label { display: grid; gap: 6px; color: #596175; font-size: 11px; font-weight: 700; }
.resummary-panel .share-option { display: flex; align-items: flex-start; gap: 9px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.72); line-height: 1.6; }
.share-option input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--accent); }
.resummary-panel select { width: 100%; height: 42px; font-size: 12px; }
.instruction-label { margin-top: 11px; }
.resummary-instruction { width: 100%; resize: vertical; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: white; font: 12px/1.6 "Noto Sans JP", sans-serif; }
.run-resummary, .adopt-summary { width: 100%; margin-top: 12px; padding: 11px 14px; border: 0; border-radius: 11px; color: white; background: var(--accent); font-weight: 700; }
.run-resummary:disabled { opacity: .6; cursor: wait; }
.reset-summary { padding: 7px 9px; border: 1px solid #d7daeb; border-radius: 8px; color: #687086; background: white; font-size: 10px; }
.resummary-note, .resummary-status { margin: 9px 0 0; color: #777f91; font-size: 10px; line-height: 1.6; }
.resummary-status { color: #4d50b8; font-weight: 600; }
.resummary-preview { margin-top: 15px; padding: 16px; border: 1px solid #d9dcef; border-radius: 13px; background: white; }
.resummary-preview h4 { margin: 6px 0 8px; font-size: 16px; line-height: 1.6; }
.resummary-preview > p { margin: 0; color: #505a6e; font-size: 13px; line-height: 1.8; }
.resummary-preview details { margin-top: 12px; }
.resummary-preview summary { cursor: pointer; color: #5557c7; font-size: 12px; font-weight: 700; }
.saved-variants { display: grid; gap: 7px; margin-top: 18px; padding-top: 15px; border-top: 1px solid #dfe2ee; }
.saved-variants h4, .saved-variants p { margin: 0; color: #697386; font-size: 11px; }
.saved-variants button { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid #dde0ef; border-radius: 10px; color: var(--ink); background: white; text-align: left; }
.saved-variants button:hover { border-color: #aeb1ec; }
.saved-variants button span { color: #7b8291; font-size: 10px; }
.loading-grid { min-height: 180px; opacity: .48; pointer-events: none; }
.dialog-links { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 26px; }
.dialog-links a { padding: 10px 14px; border-radius: 10px; color: white; background: var(--accent); text-decoration: none; font-size: 12px; font-weight: 700; }
.dialog-links a.secondary { color: var(--ink); background: #edf0f5; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) { .paper-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .site-header { padding: 20px 16px 12px; align-items: flex-start; }
  .update-box { padding: 7px; }
  .update-box > span:not(.live-dot) { display: none; }
  main { padding: 0 14px 40px; }
  .hero { min-height: 170px; padding: 22px 16px; align-items: flex-start; flex-direction: column; }
  .date-nav { width: 100%; gap: 9px; flex-wrap: wrap; }
  .date-nav > div { flex: 1; min-width: 160px; }
  .today-button { width: 100%; }
  .hero-copy { text-align: left; }
  .toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .search-box { grid-column: 1 / -1; }
  .toolbar select { min-width: 0; width: 100%; }
  .paper-grid { grid-template-columns: 1fr; }
  .dialog-body { padding: 22px 20px 30px; }
  .resummary-controls { grid-template-columns: 1fr; }
}
