:root {
  --ink: #18231f;
  --muted: #68716d;
  --paper: #f7f5ef;
  --white: #fff;
  --mint: #d8f36b;
  --green: #24624d;
  --line: #d9ddd7;
  --orange: #ff8a5b;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header {
  height: 78px;
  padding: 0 clamp(24px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(247, 245, 239, .92);
  border-bottom: 1px solid rgba(24,35,31,.1);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .04em;
}

.brand-mark { width: 32px; height: 32px; position: relative; display: block; }
.brand-mark i { position: absolute; width: 10px; height: 10px; background: var(--green); border-radius: 50%; }
.brand-mark i:first-child { left: 0; top: 11px; }
.brand-mark i:nth-child(2) { right: 0; top: 2px; background: var(--orange); }
.brand-mark i:last-child { right: 1px; bottom: 1px; background: var(--mint); border: 1px solid var(--green); }
.brand-mark::before, .brand-mark::after { content:""; position:absolute; height:1px; width:19px; background:var(--green); left:7px; top:14px; transform:rotate(-27deg); transform-origin:left; }
.brand-mark::after { transform:rotate(31deg); top:17px; }

.reset-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.header-actions { display:flex; gap:8px; }
.reset-button:hover { background: white; }
.reset-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.hero {
  max-width: 1080px;
  margin: auto;
  padding: clamp(24px, 6vw, 48px) 24px 24px;
  text-align: center;
}

.eyebrow, .section-label {
  margin: 0 0 25px;
  font: 700 11px/1 "DM Sans", sans-serif;
  letter-spacing: .22em;
  color: var(--green);
}
.eyebrow { display: flex; justify-content: center; align-items: center; gap: 10px; }
.eyebrow span { width: 18px; height: 1px; background: var(--green); }

.hero h1 {
  font-size: clamp(42px, 6.2vw, 76px);
  line-height: 1.23;
  letter-spacing: -.055em;
  margin: 0;
  font-weight: 600;
}
.hero h1 em { font-style: normal; position: relative; z-index: 1; }
.hero h1 em::after { content:""; position:absolute; left:-4px; right:-6px; height:19px; bottom:3px; background:var(--mint); z-index:-1; transform:rotate(-1deg); }
.lead { color: var(--muted); line-height: 2; font-size: 15px; margin: 30px 0 38px; }

.search-form {
  max-width: 720px;
  margin: auto;
  padding: 8px;
  display: flex;
  background: white;
  border: 1px solid #d4d8d2;
  border-radius: 14px;
  box-shadow: 0 14px 42px rgba(27, 42, 35, .08);
}
.input-wrap { flex: 1; display: flex; align-items: center; }
.input-wrap svg { width: 21px; margin-left: 16px; fill: none; stroke: #8b938f; stroke-width: 1.6; }
.input-wrap input { width: 100%; border: 0; outline: 0; padding: 15px 14px; background: transparent; font-size: 16px; }
.input-wrap input::placeholder { color: #a6aaa8; }
.search-form > button {
  border: 0;
  padding: 0 25px;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-weight: 600;
}
.search-form > button:hover { background: var(--green); }
.search-form > button span { margin-left: 14px; }
.examples { margin-top: 17px; color: #8a918e; font-size: 12px; }
.examples button { border: 0; padding: 4px 7px; background: transparent; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: #64706b; }
.api-status { display:flex; align-items:center; justify-content:center; gap:8px; margin:13px 0 -4px; color:#8a918e; font-size:11px; }
.api-status i { width:7px; height:7px; border-radius:50%; background:#c0c5c2; }
.api-status.ready i { background:#42a477; box-shadow:0 0 0 3px rgba(66,164,119,.12); }
.api-status.ready span { color:var(--green); }
.search-form.loading { opacity:.72; pointer-events:none; }
.search-form.loading > button span { display:inline-block; animation:spin 1s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

.ad-unit {
  width: 100%;
  max-width: 1180px;
  min-height: 90px;
  margin: 0 auto 48px;
  padding: 0 24px;
  overflow: hidden;
}
.ad-unit .adsbygoogle {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.workspace {
  display: none;
  max-width: 1180px;
  margin: 0 auto 64px;
  padding: 0 24px;
}
.workspace.visible { display: block; animation: rise .5s ease both; }
@keyframes rise { from { opacity:0; transform:translateY(18px); } }
.workspace-head { display:flex; justify-content:space-between; align-items:end; margin-bottom:24px; }
.workspace-head .section-label { margin-bottom: 12px; }
.workspace-head h2 { margin:0; font-size:clamp(25px,4vw,38px); letter-spacing:-.04em; }
.workspace-head h2 span { color: var(--green); }
.workspace-head > p { color:var(--muted); line-height:1.8; font-size:12px; margin:0; }

.map-panel {
  height: 500px;
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: #e7efe8;
  border: 1px solid #d5e1d7;
}
.map-panel::before { content:""; position:absolute; width:380px; height:380px; border:1px solid rgba(36,98,77,.13); border-radius:50%; left:50%; top:50%; transform:translate(-50%,-50%); }
.map-panel::after { content:""; position:absolute; width:550px; height:550px; border:1px solid rgba(36,98,77,.08); border-radius:50%; left:50%; top:50%; transform:translate(-50%,-50%); }
.word-map { position:relative; width:100%; height:100%; z-index:2; }
.center-node, .word-node {
  position: absolute;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  transform:translate(-50%,-50%);
  text-align:center;
}
.center-node {
  left:50%; top:50%; width:128px; height:128px;
  padding:15px;
  background:var(--ink); color:white; border:7px solid rgba(255,255,255,.65);
  font-size:18px; font-weight:700; box-shadow:0 14px 30px rgba(24,35,31,.2);
  z-index:4;
}
.word-node {
  width:100px; height:100px;
  border:1px solid rgba(36,98,77,.25);
  background:rgba(255,255,255,.92);
  font-size:14px; font-weight:600; cursor:pointer;
  box-shadow:0 8px 20px rgba(36,70,55,.07);
  animation:pop .45s cubic-bezier(.2,.8,.2,1) both;
  z-index:3;
}
.word-connector {
  position:absolute;
  left:50%;
  top:50%;
  height:1px;
  background:rgba(36,98,77,.26);
  transform-origin:left center;
  z-index:1;
  pointer-events:none;
  animation:line-in .45s ease both;
}
.word-node:hover { background:var(--mint); border-color:var(--green); transform:translate(-50%,-50%) scale(1.08); }
@keyframes pop { from { opacity:0; transform:translate(-50%,-50%) scale(.6); } }
@keyframes line-in { from { opacity:0; } }

.history-area { margin-top:18px; background:white; border:1px solid var(--line); border-radius:14px; padding:18px 20px; }
.history-title { display:flex; justify-content:space-between; align-items:center; font-size:12px; color:var(--muted); margin-bottom:13px; }
.history-title button { border:0; background:transparent; color:var(--green); font-size:12px; cursor:pointer; }
.history-title button:disabled { opacity:.35; cursor:default; }
.history-list { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.history-chip { border:1px solid var(--line); border-radius:99px; background:var(--paper); padding:7px 13px; font-size:12px; cursor:pointer; }
.history-chip.active { background:var(--ink); color:white; border-color:var(--ink); }
.history-arrow { color:#a5aaa7; font-size:12px; }

.how-to {
  background:var(--ink);
  color:white;
  padding:54px max(24px, calc((100vw - 1132px)/2));
  display:grid;
  grid-template-columns: .85fr 1.15fr;
  gap:80px;
}
.how-to .section-label { color:var(--mint); margin-bottom:18px; }
.how-to h2 { font-size:clamp(27px,3.5vw,42px); line-height:1.5; letter-spacing:-.04em; margin:0; }
.how-to ol { margin:0; padding:0; list-style:none; }
.how-to li { display:grid; grid-template-columns:55px 1fr; gap:15px; padding:20px 0; border-bottom:1px solid rgba(255,255,255,.14); }
.how-to li:first-child { padding-top:0; }
.how-to li > span { color:var(--mint); font:600 13px "DM Sans"; }
.how-to strong { font-size:16px; }
.how-to li p { color:#aeb8b4; font-size:12px; margin:6px 0 0; }

footer { display:flex; justify-content:space-between; padding:28px max(24px,calc((100vw - 1132px)/2)); color:#838b87; font-size:10px; letter-spacing:.08em; }
footer span { margin:0 8px; }
footer a { color:inherit; text-underline-offset:3px; }
footer a:hover { color:var(--green); }

.settings-dialog { width:min(520px,calc(100% - 28px)); padding:0; border:0; border-radius:22px; color:var(--ink); box-shadow:0 30px 90px rgba(12,28,21,.3); }
.settings-dialog::backdrop { background:rgba(17,30,24,.58); backdrop-filter:blur(5px); }
.settings-dialog form { padding:38px; }
.settings-dialog .section-label { margin-bottom:13px; }
.settings-dialog h2 { margin:0 0 13px; font-size:29px; letter-spacing:-.04em; }
.dialog-lead { margin:0 0 28px; color:var(--muted); font-size:13px; line-height:1.8; }
.settings-dialog label { display:block; margin-bottom:8px; font-size:12px; font-weight:700; }
.key-input { display:flex; border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.key-input:focus-within { border-color:var(--green); box-shadow:0 0 0 3px rgba(36,98,77,.09); }
.key-input input { flex:1; min-width:0; padding:14px; border:0; outline:0; font-family:monospace; }
.key-input button { border:0; border-left:1px solid var(--line); background:#f7f7f4; padding:0 14px; font-size:11px; cursor:pointer; }
.privacy-note { color:#828985; font-size:10px; line-height:1.6; margin:10px 0 0; }
.settings-error { min-height:18px; margin:8px 0 0; color:#b74134; font-size:11px; }
.save-settings { width:100%; border:0; border-radius:9px; background:var(--ink); color:white; padding:14px; font-weight:700; cursor:pointer; }
.save-settings:hover { background:var(--green); }
.settings-dialog form > a { display:block; text-align:center; color:var(--green); font-size:11px; margin-top:15px; }
.dialog-close { position:absolute; right:17px; top:13px; border:0; background:transparent; color:#8b928f; font-size:25px; cursor:pointer; }
.word-node:disabled { cursor:wait; opacity:.65; }
.map-panel.generating .center-node::after { content:""; position:absolute; inset:-13px; border:2px solid transparent; border-top-color:var(--mint); border-radius:50%; animation:spin 1s linear infinite; }

@media (max-width: 700px) {
  .site-header { height:66px; padding:0 18px; }
  .reset-button { padding:9px; font-size:0; }
  .header-actions { gap:5px; }
  .hero { padding:42px 18px 44px; }
  .hero h1 { font-size:39px; }
  .lead br { display:none; }
  .search-form { flex-direction:column; padding:7px; }
  .search-form > button { height:50px; }
  .examples { line-height:2; }
  .ad-unit { min-height:60px; margin-bottom:32px; padding:0 14px; }
  .workspace { padding:0 12px; margin-bottom:48px; }
  .workspace-head > p { display:none; }
  .map-panel { height:480px; border-radius:18px; }
  .map-panel::before { width:280px; height:280px; }
  .center-node { width:100px; height:100px; font-size:15px; }
  .word-node { width:80px; height:80px; font-size:12px; }
  .how-to { grid-template-columns:1fr; gap:34px; padding:46px 24px; }
  footer { flex-direction:column; gap:8px; }
  .settings-dialog form { padding:32px 22px 25px; }
}
