/* common.css — 全サイト共通（進捗ウィジェット・トースト・モーダル・待ち表示・チャット基礎） */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif; line-height: 1.6; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.small { font-size: .85em; opacity: .8; }

/* ---------- トースト ---------- */
#arg-toast-root { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 9000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.arg-toast { background: rgba(20, 22, 30, .95); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35); opacity: 0; transform: translateY(12px); transition: .3s; text-align: center; max-width: 100%; }
.arg-toast.show { opacity: 1; transform: translateY(0); }
.arg-toast.star { background: linear-gradient(135deg, #1e1b4b, #312e81); border: 1px solid #fde68a; }
.arg-toast.star b { color: #fde68a; font-size: 16px; }
.arg-toast.err { background: #7f1d1d; }

/* ---------- モーダル ---------- */
.arg-modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 9500; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: .2s; }
.arg-modal-wrap.show { opacity: 1; }
.arg-modal { background: #fff; color: #111; border-radius: 16px; width: min(100%, 520px); max-height: 88vh; overflow: auto; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.4); transform: translateY(10px); transition: .2s; }
.arg-modal-wrap.show .arg-modal { transform: none; }
.arg-modal-body { padding: 22px; }
.arg-modal-body h3 { margin: 0 0 10px; font-size: 18px; }
.arg-modal-x { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; font-size: 22px; width: 36px; height: 36px; border-radius: 50%; color: #333; }
.arg-modal-x:hover { background: #eee; }
.arg-modal.dark { background: #1f2230; color: #eee; }
.arg-modal.dark .arg-modal-x { color: #ddd; }
.arg-modal.dark .arg-modal-x:hover { background: #333; }
.arg-modal.adm { background: #111827; color: #e5e7eb; }
.adm-flags, .adm-stars, .adm-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.adm-flags button, .adm-stars button, .adm-row button { border: 1px solid #374151; background: #1f2937; color: #e5e7eb; border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.adm-flags button.on, .adm-stars button.on { background: #4f46e5; border-color: #6366f1; }
.adm-row a { color: #93c5fd; margin-right: 8px; }
.pg-code { width: 100%; font-family: monospace; font-size: 12px; border: 1px solid #ccc; border-radius: 8px; padding: 8px; word-break: break-all; }

/* ---------- 待ち表示 ---------- */
.arg-wait { border: 1px dashed rgba(128,128,128,.6); border-radius: 12px; padding: 14px; margin: 12px 0; text-align: center; font-size: 14px; background: rgba(128,128,128,.08); }
.arg-wait-label { font-weight: 600; margin-bottom: 4px; }
.arg-wait-time { opacity: .8; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.arg-wait-skip, .arg-wait-hold { border: 0; border-radius: 999px; padding: 8px 18px; font-size: 14px; font-weight: 600; background: #4f46e5; color: #fff; position: relative; overflow: hidden; }
.arg-wait-hold::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,255,255,.35); transition: width 1.5s linear; }
.arg-wait-hold.holding::after { width: 100%; }
.arg-wait-note { font-size: 12px; opacity: .7; margin-top: 8px; }

/* ---------- 入力中 ---------- */
.arg-typing { font-size: 13px; opacity: .75; padding: 6px 12px; display: flex; align-items: center; gap: 6px; }
.arg-typing .dots i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 3px; animation: argdot 1.2s infinite; }
.arg-typing .dots i:nth-child(2) { animation-delay: .2s; } .arg-typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes argdot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- チャット共通 ---------- */
.chat-log { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; animation: chatin .25s ease; }
@keyframes chatin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-msg .av { width: 36px; height: 36px; border-radius: 50%; flex: none; background-size: cover; }
.chat-msg .body { min-width: 0; max-width: min(82%, 560px); display: flex; flex-direction: column; align-items: flex-start; }
.chat-msg.me .body { align-items: flex-end; }
.chat-msg .bubble { padding: 9px 14px; border-radius: 18px; max-width: 100%; word-break: normal; overflow-wrap: anywhere; line-break: strict; white-space: pre-wrap; font-size: 15px; line-height: 1.55; text-align: left; }
.chat-msg .meta { font-size: 11px; opacity: .6; margin: 0 6px 4px; }
.chat-msg .meta .tm { margin-left: 6px; }
.chat-msg.me { flex-direction: row-reverse; }
.chat-msg.sys { justify-content: center; }
.chat-msg.sys .bubble { background: transparent; font-size: 12px; opacity: .7; text-align: center; max-width: 90%; }
@media (max-width: 480px) { .chat-msg .body { max-width: 88%; } .chat-msg .bubble { font-size: 15px; padding: 8px 12px; } }
.chat-day { text-align: center; font-size: 12px; opacity: .6; margin: 10px 0 4px; }
.chat-choices { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 12px; align-items: flex-end; }
.chat-choices button { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 18px; padding: 8px 14px; font-size: 14px; text-align: left; max-width: 90%; }
.chat-choices button:hover { background: rgba(128,128,128,.15); }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid rgba(128,128,128,.25); }
.chat-input input { flex: 1; border-radius: 20px; border: 1px solid rgba(128,128,128,.4); padding: 10px 14px; font-size: 15px; background: rgba(128,128,128,.08); color: inherit; min-width: 0; }
.chat-input button { border: 0; border-radius: 20px; padding: 0 16px; background: #4f46e5; color: #fff; font-weight: 600; }
.chat-input button:disabled { opacity: .4; cursor: default; }
.chat-showall { align-self: center; font-size: 12px; border: 1px solid rgba(128,128,128,.4); background: rgba(128,128,128,.1); color: inherit; border-radius: 999px; padding: 4px 12px; margin: 4px auto; }
.chat-locked { text-align: center; font-size: 12px; opacity: .6; padding: 10px; }

/* ---------- 進捗ウィジェット ---------- */
#arg-progress { position: fixed; right: max(14px, env(safe-area-inset-right, 0px)); bottom: max(14px, env(safe-area-inset-bottom, 0px)); z-index: 8500; font-family: inherit; }
#arg-pg-btn { display: flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; background: #111827; color: #fde68a; padding: 10px 14px; font-weight: 700; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.35); border: 1px solid rgba(253,230,138,.35); transition: transform .15s; }
#arg-pg-btn:hover { transform: translateY(-2px); }
#arg-pg-btn.full { background: linear-gradient(135deg, #312e81, #1e1b4b); border-color: #fde68a; }
#arg-pg-btn.new::after { content: "NEW"; position: absolute; top: -8px; left: -6px; background: #ef4444; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px; }
#arg-pg-btn { position: relative; }
#arg-pg-panel { position: absolute; right: 0; bottom: 52px; width: min(360px, calc(100vw - 28px)); max-height: min(70vh, 640px); overflow: auto; background: #0f172a; color: #e5e7eb; border-radius: 16px; box-shadow: 0 16px 50px rgba(0,0,0,.5); border: 1px solid #1f2937; font-size: 14px; }
.pg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #1f2937; position: sticky; top: 0; background: #0f172a; z-index: 1; }
.pg-title { font-weight: 700; }
.pg-close { border: 0; background: transparent; color: #9ca3af; font-size: 20px; width: 32px; height: 32px; border-radius: 50%; }
.pg-close:hover { background: #1f2937; color: #fff; }
.pg-body { padding: 12px 14px 16px; }
.pg-chapter { background: #111827; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; border-left: 3px solid #fde68a; }
.pg-ch-n { font-weight: 700; }
.pg-ch-goal { font-size: 13px; color: #cbd5e1; margin-top: 2px; }
.pg-sites { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.pg-sites a { text-align: center; text-decoration: none; font-size: 12px; font-weight: 600; padding: 7px 4px; border-radius: 8px; background: #1e293b; color: #cbd5e1; border: 1px solid #334155; }
.pg-sites a.on { background: #4f46e5; color: #fff; border-color: #6366f1; }
.pg-sec { margin-bottom: 14px; }
.pg-sec-t { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; margin-bottom: 6px; display: flex; justify-content: space-between; }
.pg-stars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.pg-star { border: 1px solid #334155; background: #1e293b; color: #475569; border-radius: 10px; width: auto; aspect-ratio: 1; min-width: 0; font-size: 18px; position: relative; padding: 0; }
.pg-star small { position: absolute; right: 4px; bottom: 2px; font-size: 9px; }
.pg-star.on { color: #fde68a; border-color: #fde68a; background: #1e1b4b; text-shadow: 0 0 8px #fde68a; }
.pg-hint { margin-top: 8px; font-size: 13px; background: #1e293b; border-radius: 8px; padding: 8px 10px; color: #e2e8f0; }
.pg-hint small { color: #94a3b8; }
.pg-site { background: #111827; border-radius: 10px; margin-bottom: 6px; }
.pg-site summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.pg-site summary::-webkit-details-marker { display: none; }
.pg-site-n { font-weight: 600; flex: none; width: 74px; }
.pg-site-c { font-size: 12px; color: #94a3b8; width: 36px; }
.pg-bar { flex: 1; height: 6px; background: #1f2937; border-radius: 3px; overflow: hidden; }
.pg-bar i { display: block; height: 100%; background: #fde68a; }
.pg-site ul { list-style: none; margin: 0; padding: 0 10px 8px 10px; }
.pg-site li { font-size: 13px; padding: 3px 0 3px 18px; position: relative; color: #64748b; }
.pg-site li::before { content: "○"; position: absolute; left: 0; }
.pg-site li.done { color: #e2e8f0; }
.pg-site li.done::before { content: "✓"; color: #34d399; }
.pg-site li a { text-decoration: none; }
.pg-site li a:hover { text-decoration: underline; }
.pg-ends { display: flex; gap: 6px; }
.pg-end { flex: 1; background: #111827; border: 1px solid #1f2937; border-radius: 10px; padding: 8px; text-align: center; font-weight: 700; color: #475569; display: flex; flex-direction: column; }
.pg-end small { font-weight: 400; font-size: 11px; }
.pg-end.on { color: #fde68a; border-color: #fde68a; }
.pg-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.pg-seg { display: flex; border: 1px solid #334155; border-radius: 8px; overflow: hidden; }
.pg-seg button { border: 0; background: transparent; color: #94a3b8; padding: 5px 10px; font-size: 12px; }
.pg-seg button.on { background: #4f46e5; color: #fff; }
.pg-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.pg-links button, .pg-links a { border: 1px solid #334155; background: #1e293b; color: #e2e8f0; border-radius: 8px; padding: 6px 10px; font-size: 12px; text-decoration: none; }
.pg-links .danger { border-color: #7f1d1d; color: #fca5a5; }
.pg-copy, .pg-load { margin-top: 8px; border: 0; border-radius: 8px; background: #4f46e5; color: #fff; padding: 8px 14px; }
.pg-name { color: #e2e8f0; }

@media (max-width: 480px) {
  #arg-pg-panel { position: fixed; left: 12px; right: 12px; bottom: 70px; width: auto; max-height: 72vh; }
}
