:root {
  --bg-app: #313338;
  --bg-topbar: #2b2d31;
  --bg-card: #2b2d31;
  --bg-elevated: #1e1f22;
  --bg-input: #1e1f22;
  --bg-hover: #35373c;
  --bg-tile: #383a40;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #23a55a;
  --green-hover: #1a8347;
  --red: #da373c;
  --red-hover: #b42b2f;
  --yellow: #f0b232;
  --text: #f2f3f5;
  --text-2: #dbdee1;
  --muted: #b5bac1;
  --faint: #949ba4;
  --link: #00a8fc;
  --border: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  font-family: "gg sans", "Noto Sans JP", "Noto Sans", system-ui, -apple-system, "Segoe UI",
    "Hiragino Kaku Gothic ProN", Meiryo, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text-2);
  background: var(--bg-app);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: -30% -30% auto -30%;
  height: 70vh;
  background: radial-gradient(closest-side, rgba(88, 101, 242, 0.18), transparent 70%);
  z-index: 0;
  pointer-events: none;
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-6%, -4%, 0) scale(1); }
  to { transform: translate3d(8%, 6%, 0) scale(1.15); }
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px clamp(10px, 3vw, 24px);
  min-height: 54px;
  background: rgba(43, 45, 49, 0.85);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; min-width: 0; flex: 1 1 auto; }
.brand .logo {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px; overflow: hidden;
  background: var(--blurple);
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.5);
}
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { display: block; color: var(--faint); font-weight: 500; font-size: 11px; }

.user-box { display: flex; align-items: center; gap: 6px; font-size: 14px; min-width: 0; flex: 0 0 auto; }
.user-box .name {
  display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 5px;
  border-radius: 999px; background: var(--bg-elevated); font-weight: 600; max-width: 42vw; overflow: hidden;
}
.user-box .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box img { width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto; }

main { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: clamp(14px, 3vw, 28px) clamp(12px, 3vw, 16px) 80px; }

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: clamp(16px, 4vw, 24px);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
main > .card:nth-of-type(2) { animation-delay: 0.06s; }
main > .card:nth-of-type(3) { animation-delay: 0.12s; }
main > .card:nth-of-type(4) { animation-delay: 0.18s; }
main > .card:nth-of-type(5) { animation-delay: 0.24s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.card h2 { margin: 0 0 6px; font-size: 17px; color: var(--text); font-weight: 800; }
.card h3 { margin: 20px 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 800; }
.lead { color: var(--muted); margin: 0 0 14px; font-size: 14px; }

.hero { text-align: center; }
.hero .mascot {
  width: 76px; height: 76px; margin: 4px auto 10px; border-radius: 50%;
  background: var(--bg-elevated); display: grid; place-items: center; font-size: 36px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: pop 0.5s cubic-bezier(0.22, 1.4, 0.4, 1) both;
}
.hero .mascot img { width: 100%; height: 100%; object-fit: cover; }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.hero h1 { margin: 6px 0 4px; font-size: clamp(20px, 5vw, 26px); color: var(--text); font-weight: 800; }
.hero .sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.rate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rate-grid.panel-rates { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
.rate-grid.panel-rates .value { font-size: clamp(16px, 4.5vw, 22px); }
.rate-item { background: var(--bg-elevated); border-radius: 12px; padding: 14px; min-width: 0; transition: transform 0.15s ease, background 0.15s ease; }
.rate-item:hover { transform: translateY(-2px); background: #23252a; }
.rate-item .label { color: var(--faint); font-size: 12px; font-weight: 700; }
.rate-item .value { font-size: clamp(18px, 5vw, 24px); font-weight: 800; margin-top: 4px; color: var(--text); overflow-wrap: anywhere; }
.rate-item .value.small { font-size: clamp(15px, 4vw, 18px); }
.rate-item .value.accent { color: var(--green); }

ul.notes { margin: 6px 0 0; padding: 0; list-style: none; }
ul.notes li { position: relative; padding: 7px 0 7px 22px; color: var(--muted); font-size: 13px; }
ul.notes li + li { border-top: 1px solid var(--border); }
ul.notes li::before { content: "•"; position: absolute; left: 6px; top: 6px; color: var(--blurple); font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
button, .btn {
  appearance: none; border: none; background: var(--bg-tile); color: var(--text);
  padding: 11px 16px; border-radius: 10px; font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; line-height: 1.2;
  position: relative; overflow: hidden;
}
.ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.35); transform: scale(0); animation: ripple 0.6s ease-out; pointer-events: none; }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
button:hover, .btn:hover { background: #404249; text-decoration: none; }
button:active { transform: translateY(1px) scale(0.98); }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--blurple); color: #fff; box-shadow: 0 6px 16px rgba(88, 101, 242, 0.35); }
.btn-primary:hover { background: var(--blurple-hover); box-shadow: 0 8px 22px rgba(88, 101, 242, 0.45); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-hover); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { min-height: 48px; font-size: 15px; padding: 14px 22px; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.action-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px; text-align: left; background: var(--bg-elevated); min-height: 0; transition: transform 0.15s ease, background 0.15s ease; }
.action-tile:hover { background: var(--bg-hover); transform: translateY(-2px); }
.action-tile .ico { font-size: 20px; }
.action-tile .t { font-weight: 800; font-size: 14px; color: var(--text); }
.action-tile .d { font-weight: 400; font-size: 11.5px; color: var(--faint); }

.btn.loading { pointer-events: none; color: transparent !important; position: relative; }
.btn.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { margin-top: 16px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 8px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; }
label .opt { color: var(--faint); font-weight: 500; text-transform: none; letter-spacing: 0; }
input, select, textarea { width: 100%; background: var(--bg-input); border: 1px solid rgba(0, 0, 0, 0.3); border-radius: 8px; color: var(--text); padding: 12px; font-size: 16px; font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 78px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blurple); box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.25); }
.hint { color: var(--faint); font-size: 12px; margin-top: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 150px; min-width: 0; }

.estimator { background: var(--bg-elevated); border-radius: 12px; padding: 14px; margin-top: 14px; }
.estimator .field { margin-top: 0; }
.estimator .out { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.estimator .out .k { color: var(--faint); font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.estimator .out .v { color: var(--green); font-size: 20px; font-weight: 800; text-align: right; overflow-wrap: anywhere; min-width: 0; flex: 1 1 auto; }
.estimator .sub-v { color: var(--muted); font-size: 12px; margin-top: 4px; text-align: right; }

.msg { border-radius: 10px; padding: 12px 14px 12px 42px; margin-top: 16px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; position: relative; background: var(--bg-elevated); border-left: 3px solid var(--faint); animation: rise 0.25s ease both; }
.msg::before { position: absolute; left: 13px; top: 11px; font-size: 15px; }
.msg.ok { border-color: var(--green); } .msg.ok::before { content: "✅"; }
.msg.err { border-color: var(--red); } .msg.err::before { content: "⚠️"; }
.msg.info { border-color: var(--blurple); } .msg.info::before { content: "ℹ️"; }
.msg a { color: var(--link); font-weight: 700; }
.msg .retry { margin-top: 10px; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 6px; color: #fff; background: var(--faint); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.tag.ok { background: var(--green); } .tag.warn { background: var(--yellow); color: #2b2100; } .tag.err { background: var(--red); }

.copy { background: var(--bg-tile); border: none; color: var(--muted); font-size: 11px; font-weight: 700; padding: 4px 9px; min-height: 0; border-radius: 6px; margin-left: 6px; }
.copy:hover { background: var(--bg-hover); color: var(--text); }
.copy.done { background: var(--green); color: #fff; }

.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.8); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 560px) { .overlay { align-items: center; padding: 20px; } }
.modal { width: 100%; max-width: 460px; background: var(--bg-app); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg); padding: 18px clamp(16px, 5vw, 20px) calc(20px + env(safe-area-inset-bottom)); max-height: 90vh; max-height: 90dvh; overflow-y: auto; animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1) both; }
@media (min-width: 560px) { .modal { border-radius: 14px; padding-bottom: 20px; animation: popIn 0.2s cubic-bezier(0.22, 1.3, 0.4, 1) both; } }
@keyframes slideUp { from { transform: translateY(50px); } to { transform: none; } }
@keyframes popIn { from { transform: scale(0.94); opacity: 0.3; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 18px; color: var(--text); font-weight: 800; }
.modal-close { background: transparent; color: var(--faint); width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 8px; font-size: 20px; }
.modal-close:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.amount-badge { text-align: center; background: var(--bg-elevated); border-radius: 12px; padding: 16px; margin: 14px 0; }
.amount-badge .label { color: var(--faint); font-size: 12px; font-weight: 700; }
.amount-badge .value { font-size: 34px; font-weight: 800; margin-top: 4px; color: var(--text); }

.mini-card { background: var(--bg-elevated); border-radius: 12px; padding: 15px; margin: 12px 0; animation: rise 0.35s ease both; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 14px; margin: 12px 0; font-size: 13.5px; }
.kv dt { color: var(--faint); white-space: nowrap; }
.kv dd { margin: 0; min-width: 0; text-align: right; overflow-wrap: anywhere; word-break: break-all; color: var(--text-2); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--bg-elevated); border-radius: 12px; padding: 14px; transition: transform 0.15s ease; }
.stat:hover { transform: translateY(-2px); }
.stat .k { color: var(--faint); font-size: 11.5px; font-weight: 700; }
.stat .v { color: var(--text); font-size: 21px; font-weight: 800; margin-top: 4px; overflow-wrap: anywhere; }
.stat .v.accent { color: var(--green); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar select, .toolbar input { width: auto; flex: 1 1 140px; }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 520px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--faint); font-weight: 800; text-transform: uppercase; font-size: 11px; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.feed-item { border-left: 3px solid var(--faint); padding: 8px 12px 12px; margin-bottom: 6px; background: var(--bg-elevated); border-radius: 0 8px 8px 0; animation: rise 0.3s ease both; }
.feed-item.warning { border-color: var(--yellow); }
.feed-item.success { border-color: var(--green); }
.feed-item .t { font-weight: 800; font-size: 13.5px; color: var(--text); }
.feed-item .b { color: var(--muted); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.feed-item .d { color: var(--faint); font-size: 11px; margin-top: 5px; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; background: var(--bg-elevated); border-radius: 10px; padding: 11px 16px 11px 40px; font-size: 13.5px; box-shadow: var(--shadow-lg); position: relative; max-width: 92vw; border-left: 3px solid var(--faint); color: var(--text-2); animation: toastIn 0.28s cubic-bezier(0.22, 1.2, 0.4, 1) both; }
.toast::before { position: absolute; left: 13px; top: 11px; }
.toast.ok { border-color: var(--green); } .toast.ok::before { content: "✅"; }
.toast.err { border-color: var(--red); } .toast.err::before { content: "⚠️"; }
.toast.info { border-color: var(--blurple); } .toast.info::before { content: "ℹ️"; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 0; color: var(--faint); font-size: 13.5px; }
.loader .ring { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--blurple); animation: spin 0.8s linear infinite; }

.brand .logo { position: relative; }
.status-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2.5px solid var(--bg-topbar); box-shadow: 0 0 0 0 rgba(35, 165, 90, 0.6); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(35, 165, 90, 0.5); } 70% { box-shadow: 0 0 0 6px rgba(35, 165, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(35, 165, 90, 0); } }

.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-left: 4px; vertical-align: middle; animation: blink 1.4s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.flash-up { animation: flashUp 0.9s ease; }
.flash-down { animation: flashDown 0.9s ease; }
@keyframes flashUp { 0% { color: var(--green); text-shadow: 0 0 14px rgba(35, 165, 90, 0.7); transform: translateY(-2px); } 100% { color: var(--green); text-shadow: none; transform: none; } }
@keyframes flashDown { 0% { color: var(--red); text-shadow: 0 0 14px rgba(218, 55, 60, 0.7); transform: translateY(2px); } 100% { color: var(--green); text-shadow: none; transform: none; } }

.tip { position: fixed; z-index: 300; transform: translate(-50%, -100%); background: #111214; color: #f2f3f5; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 6px; pointer-events: none; opacity: 0; transition: opacity 0.12s ease; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); white-space: nowrap; }
.tip::after { content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #111214; }

.skeleton { background: linear-gradient(90deg, #2a2c31 25%, #34363c 50%, #2a2c31 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--border); margin: 20px 0; border: none; }

@media (max-width: 560px) {
  .rate-grid.panel-rates { grid-template-columns: 1fr 1fr; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .card h2 { font-size: 16px; }
}
@media (max-width: 440px) {
  .topbar { gap: 6px; padding: 10px 12px; }
  .brand { font-size: 15px; }
  .brand small { display: none; }
  .brand .logo { width: 34px; height: 34px; }
  .user-box { gap: 5px; }
  .user-box .name { max-width: none; padding: 4px; gap: 0; }
  .user-box .name span { display: none; }
  .user-box .btn-ghost { padding: 8px 9px; font-size: 12.5px; }
  .btn { padding: 11px 13px; }
  .stat .v { font-size: 18px; }
  .rate-item .value { font-size: clamp(16px, 5.5vw, 22px); }
}
@media (max-width: 360px) {
  .rate-grid, .rate-grid.panel-rates, .action-grid, .stats { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  body::before { animation: none; }
}
