:root {
  --bg: #06101b;
  --bg-deep: #030913;
  --panel: rgba(17, 27, 39, 0.94);
  --panel-soft: rgba(24, 35, 48, 0.86);
  --line: rgba(151, 174, 199, 0.18);
  --text: #f4f7fb;
  --muted: #aeb8c5;
  --green: #69d44f;
  --green-bright: #82e764;
  --green-deep: #2d7d28;
  --yellow: #f6bd2d;
  --red: #e93b2f;
  --blue: #4ba7ff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg-deep); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 8%, rgba(41, 93, 136, 0.22), transparent 34%),
    radial-gradient(circle at 82% 72%, rgba(39, 123, 63, 0.12), transparent 28%),
    linear-gradient(160deg, #07131f 0%, #030913 72%);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.noscript,
.compatibility-banner {
  max-width: 1180px;
  margin: 14px auto;
  padding: 12px 16px;
  border: 1px solid rgba(246, 189, 45, 0.55);
  border-radius: 12px;
  background: rgba(86, 57, 5, 0.92);
  color: #fff4cf;
  text-align: center;
}

.page-shell { width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 30px 0 24px; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow { margin: 0 0 5px; color: var(--green-bright); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.08em; }
h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.55rem); letter-spacing: 0.02em; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(31, 43, 56, 0.88);
  color: #cbd5df;
  font-size: 0.86rem;
  white-space: nowrap;
}

.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 13px rgba(105, 212, 79, 0.9); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.88fr) minmax(360px, 1.08fr) minmax(280px, 0.92fr);
  align-items: start;
  gap: 22px;
}

.info-column,
.status-column { display: grid; gap: 20px; }

.info-card,
.status-card,
.app-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(25, 36, 49, 0.96), rgba(11, 20, 31, 0.96));
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

.info-card,
.status-card { border-radius: 16px; padding: 22px; }
.info-card h2,
.status-card h2,
.app-card h2 { margin: 0; font-size: 1rem; }
.section-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.heading-icon { display: grid; place-items: center; width: 30px; height: 30px; color: var(--green-bright); font-size: 1.4rem; }
.heading-icon.warning { color: var(--yellow); }

.check-list,
.warning-list { display: grid; gap: 15px; padding: 0; margin: 0; list-style: none; color: #d7dee6; font-size: 0.91rem; line-height: 1.55; }
.check-list li,
.warning-list li { position: relative; padding-left: 27px; }
.check-list li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 19px; height: 19px; border: 1px solid var(--green); border-radius: 50%; color: var(--green); font-size: 0.72rem; line-height: 17px; text-align: center; }
.warning-list li::before { content: "△"; position: absolute; left: 0; color: var(--yellow); font-weight: 800; }
.warning-card { border-color: rgba(246, 189, 45, 0.2); }
.compact-card { color: var(--muted); font-size: 0.82rem; line-height: 1.7; text-align: center; }
.compact-card p { margin: 0; }

.app-device {
  position: relative;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 16px;
  border: 1px solid rgba(192, 209, 226, 0.56);
  border-radius: 36px;
  background: linear-gradient(160deg, #0d1722, #07101a);
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(255, 255, 255, 0.025);
}

.device-topbar { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; min-height: 42px; padding: 0 6px 9px; text-align: center; }
.mini-battery { position: relative; width: 30px; height: 15px; border: 2px solid #d6dde6; border-radius: 3px; }
.mini-battery::after { content: ""; position: absolute; right: -5px; top: 3px; width: 3px; height: 6px; border-radius: 0 2px 2px 0; background: #d6dde6; }
.mini-battery span { display: block; width: 50%; height: 100%; background: var(--green); transition: width 0.4s ease; }
.icon-button,
.help-dot { border: 0; color: var(--green-bright); background: transparent; cursor: pointer; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; font-weight: 800; }
.help-dot { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 1px solid var(--green); border-radius: 50%; font-size: 0.72rem; font-weight: 800; }

.app-card { margin-top: 12px; padding: 16px; border-radius: 13px; }
.card-title-row { display: flex; align-items: center; gap: 8px; justify-content: flex-start; }
.target-output { display: block; margin: 8px auto 4px; color: var(--green); font-size: clamp(3rem, 10vw, 4rem); line-height: 1; font-weight: 800; text-align: center; text-shadow: 0 0 22px rgba(105, 212, 79, 0.16); }
input[type="range"] { width: 100%; accent-color: var(--green); cursor: pointer; }
input[type="range"]:disabled { opacity: 0.45; cursor: not-allowed; }
.range-scale { display: flex; justify-content: space-between; color: #9ba6b2; font-size: 0.77rem; }
.subtext { margin: 9px 0 0; color: var(--muted); font-size: 0.77rem; line-height: 1.55; text-align: center; }

.battery-status-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 14px; align-items: center; margin-top: 13px; }
.battery-visual { display: flex; align-items: center; gap: 13px; }
.battery-shell { position: relative; width: 37px; height: 64px; padding: 4px; border: 3px solid #ccd5df; border-radius: 7px; }
.battery-shell::before { content: ""; position: absolute; top: -8px; left: 9px; width: 14px; height: 6px; border-radius: 3px 3px 0 0; background: #ccd5df; }
.battery-shell span { display: block; position: absolute; left: 4px; right: 4px; bottom: 4px; height: 0%; border-radius: 2px; background: linear-gradient(#7de563, #47b73a); transition: height 0.45s ease; }
.battery-visual strong { color: var(--green); font-size: 2.25rem; }
.battery-details { display: grid; gap: 10px; margin: 0; }
.battery-details div { display: flex; justify-content: space-between; gap: 10px; font-size: 0.76rem; }
.battery-details dt { color: #bac4cf; }
.battery-details dd { margin: 0; color: var(--green-bright); text-align: right; }

.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.segmented-control label { cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: grid; place-items: center; min-height: 39px; border: 1px solid var(--line); border-radius: 10px; background: rgba(66, 78, 91, 0.45); color: #cad3dc; font-size: 0.84rem; font-weight: 700; transition: 0.2s ease; }
.segmented-control input:checked + span { border-color: rgba(116, 223, 88, 0.75); color: #fff; background: linear-gradient(135deg, #45a83a, #7cdb58); box-shadow: 0 7px 18px rgba(87, 191, 64, 0.2); }
.segmented-control input:disabled + span { opacity: 0.45; cursor: not-allowed; }

.timer-grid { display: grid; grid-template-columns: 1fr 1fr; margin-top: 15px; }
.timer-grid div { display: grid; gap: 5px; text-align: center; }
.timer-grid div + div { border-left: 1px solid var(--line); }
.timer-grid span { color: var(--muted); font-size: 0.74rem; }
.timer-grid strong { color: var(--green); font-size: 1.45rem; font-variant-numeric: tabular-nums; }

.run-message { min-height: 47px; display: grid; place-items: center; margin: 12px 2px 0; padding: 10px 13px; border: 1px solid rgba(75, 167, 255, 0.17); border-radius: 10px; background: rgba(12, 32, 49, 0.7); color: #bed0df; font-size: 0.78rem; line-height: 1.45; text-align: center; }
.run-message.active { border-color: rgba(105, 212, 79, 0.42); color: #dff8d9; background: rgba(22, 65, 35, 0.55); }
.run-message.warning { border-color: rgba(246, 189, 45, 0.5); color: #fff0bd; background: rgba(83, 58, 8, 0.58); }

.action-stack { display: grid; gap: 9px; margin-top: 12px; }
.action-button { min-height: 48px; border: 0; border-radius: 10px; color: #fff; font-weight: 800; cursor: pointer; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22); transition: transform 0.05s ease, filter 0.2s ease, opacity 0.2s ease; }
.action-button:active:not(:disabled) { transform: translateY(1px); }
.action-button:hover:not(:disabled) { filter: brightness(1.08); }
.action-button:disabled { opacity: 0.36; cursor: not-allowed; }
.start-button { background: linear-gradient(135deg, #4ebc3e, #7bdb55); }
.pause-button { background: linear-gradient(135deg, #434c58, #2d343e); }
.stop-button { background: linear-gradient(135deg, #ca2b22, #ef4434); }

.status-card h2 { margin-bottom: 15px; }
.activity-layout { display: grid; grid-template-columns: minmax(120px, 0.95fr) 1.05fr; gap: 15px; align-items: center; }
#activityCanvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 50%; background: radial-gradient(circle, rgba(41, 112, 41, 0.13), transparent 66%); }
.activity-layout strong { display: block; font-size: 1rem; line-height: 1.5; }
.activity-layout p { margin: 7px 0; color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.activity-layout small { color: var(--green-bright); }
.wake-layout { display: grid; grid-template-columns: 68px 1fr; gap: 15px; align-items: center; }
.sun-icon { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; color: var(--green-bright); background: rgba(69, 168, 58, 0.18); font-size: 2rem; }
.wake-layout strong { display: block; }
.wake-layout p { margin: 6px 0 0; color: var(--muted); font-size: 0.8rem; }

.history-heading { display: flex; align-items: center; justify-content: space-between; }
.text-button { padding: 4px 7px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 0.76rem; }
.history-list { display: grid; gap: 9px; max-height: 340px; overflow: auto; scrollbar-color: #506070 transparent; }
.history-item { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(7, 15, 24, 0.62); }
.history-item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.76rem; }
.history-item-head strong { color: #e5ebf1; }
.history-result { color: var(--green-bright); }
.history-result.interrupted { color: var(--yellow); }
.history-item p { margin: 6px 0 0; color: var(--muted); font-size: 0.7rem; line-height: 1.45; }
.empty-history { margin: 5px 0 0; color: var(--muted); font-size: 0.8rem; text-align: center; }

.app-dialog { width: min(92vw, 470px); border: 1px solid rgba(162, 186, 210, 0.3); border-radius: 16px; background: #101b28; color: var(--text); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }
.app-dialog form { display: grid; gap: 14px; }
.app-dialog h2 { margin: 0; }
.app-dialog p { margin: 0; color: #c8d2dc; line-height: 1.7; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dialog-actions button { min-height: 40px; padding: 8px 15px; border: 0; border-radius: 9px; color: #fff; cursor: pointer; }
.dialog-secondary { background: #3f4955; }
.dialog-primary { background: #54ba42; }
.dialog-danger { background: #d6382c; }

.site-footer { max-width: 1180px; margin: 24px auto 0; padding: 10px 0 20px; border-top: 1px solid rgba(94, 132, 176, 0.18); color: #58a6ff; text-align: center; font-size: 0.88rem; }
.site-footer a { color: #58a6ff; font-weight: 700; text-decoration: none; }
.site-footer a:hover { color: #8bc4ff; }

.ad-panel { max-width: 880px; margin: 12px auto 0; padding: 0; border: 1px solid #d7e6f8; border-radius: 10px; background: #fff; overflow: hidden; }
.ad-panel[hidden] { display: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; height: 0 !important; overflow: hidden !important; }
.ad-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 8px; background: #f4f8ff; border-bottom: 1px solid #d7e6f8; }
.ad-label { color: #4f6f91; font-size: 0.72rem; line-height: 1; }
.ad-wait-message { margin-left: auto; color: #4f6f91; font-size: 0.72rem; }
.ad-close-btn { margin: 0; padding: 3px 8px; min-height: 0; border: 0; border-radius: 999px; background: #1565c0; color: #fff; font-size: 0.72rem; font-weight: 700; cursor: pointer; }
.ad-close-btn:hover { background: #0d47a1; }
.ad-body { min-height: 90px; padding: 8px; background: #fff; }

@media (max-width: 1060px) {
  .dashboard-grid { grid-template-columns: minmax(360px, 1.1fr) minmax(280px, 0.9fr); }
  .app-device { grid-column: 1; grid-row: 1 / span 2; }
  .info-column { grid-column: 2; grid-row: 1; }
  .status-column { grid-column: 2; grid-row: 2; }
}

@media (max-width: 760px) {
  .page-shell { width: min(100% - 20px, 580px); padding-top: 18px; }
  .hero { align-items: flex-start; flex-direction: column; margin-bottom: 16px; }
  .dashboard-grid { display: flex; flex-direction: column; }
  .app-device { order: 1; width: 100%; border-radius: 24px; }
  .status-column { order: 2; width: 100%; }
  .info-column { order: 3; width: 100%; }
  .info-card, .status-card { padding: 18px; }
}

@media (max-width: 430px) {
  .page-shell { width: 100%; padding: 14px 10px 20px; }
  .app-device { padding: 10px; border-radius: 21px; }
  .app-card { padding: 14px; }
  .battery-status-grid { grid-template-columns: 1fr; }
  .battery-visual { justify-content: center; }
  .timer-grid strong { font-size: 1.2rem; }
  .activity-layout { grid-template-columns: 125px 1fr; }
  .ad-panel-head { align-items: flex-start; }
  .ad-wait-message { max-width: 180px; text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
