:root {
  --bg: #ffffff;
  --sidebar-bg: #f5f6f6;
  --text: #333;
  --text-muted: #65717b;
  --border: #d6e3ed;
  --accent: #3ea8ff;
  --surface: #f5f6f6;
  --sidebar-width: 240px;
}

[data-theme="dark"] {
  --bg: #1a1d23;
  --sidebar-bg: #21242b;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --surface: #21242b;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  padding: 20px;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 24px;
  display: block;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav a {
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  background: var(--bg);
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--bg);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contact-link {
  display: block;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  color: var(--accent);
  transition: background 0.15s, color 0.15s;
}

.contact-link:hover {
  background: var(--bg);
  color: var(--accent);
}

.theme-switch {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.theme-switch p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.theme-switch label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 6px 0;
  cursor: pointer;
}

.theme-switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Main */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content {
  width: 100%;
  max-width: 820px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-header p {
  font-size: 16px;
  color: var(--text-muted);
}

.card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 24px;
}

.card h2 {
  margin-bottom: 16px;
}

/* Form */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.form-group input,
.form-group select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

button[type="submit"] {
  width: 100%;
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}

button[type="submit"]:hover {
  opacity: 0.9;
}

.btc-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.btc-controls label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  gap: 6px;
}

.btc-controls select {
  min-width: 160px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.btc-controls button {
  height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btc-controls button:hover {
  opacity: 0.9;
}

.btc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.btc-stats div {
  padding: 16px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px dashed var(--border);
}

.status-note {
  font-size: 13px;
  color: var(--text-muted);
}

.chart-section {
  width: 80%;
  margin: 0 auto 24px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.chart-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

.chart-frame {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  padding: 0;
  min-height: 480px;
  width: 100%;
}

.echart-container {
  width: 100%;
  height: 480px;
}

.chart-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.chart-caption {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.result {
  margin-top: 24px;
  padding: 20px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.result:empty {
  display: none;
}

/* Mode Switch */
.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.mode-switch label {
  flex: 1;
}

.mode-switch input {
  display: none;
}

.mode-switch span {
  display: block;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-switch input:checked + span {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* Tool Grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.tool-grid a {
  padding: 20px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
}

.tool-grid a:hover {
  border-color: var(--accent);
}

.note {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

.ip-section {
  margin-bottom: 32px;
}

.ip-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 18px;
}

.ip-result[data-state="error"] {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.ip-result[data-state="success"] {
  border-color: var(--accent);
}

.ip-result .label {
  font-weight: 600;
  color: var(--text);
}

.ip-result .detail {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.ip-info-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.ip-info-list div {
  padding: 16px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.info-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.info-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
