:root {
  --bg: #f3efe6;
  --panel: rgba(255, 255, 255, 0.72);
  --ink: #1f2430;
  --muted: #5a6070;
  --primary: #0f766e;
  --secondary: #0f4c5c;
  --accent: #c57b29;
  --danger: #bb2c2c;
  --line: rgba(45, 56, 73, 0.14);
  --glass-border: rgba(255, 255, 255, 0.45);
  --bg-radial-a: #f9d29d;
  --bg-radial-b: #9dcfd4;
  --bg-gradient-start: #f6f1e7;
  --bg-gradient-mid: #f0ecdf;
  --bg-gradient-end: #ebe7de;
  --header-a: #0f4c5c;
  --header-b: #0f766e;
  --header-c: #c57b29;
  --orb-a: #f2c181;
  --orb-b: #8dc9cc;
  --btn-passive-bg: rgba(15, 76, 92, 0.1);
  --btn-passive-ink: #203244;
  --table-hover: rgba(15, 118, 110, 0.07);
}

body[data-theme="sunrise"] {
  --bg: #f3efe6;
  --panel: rgba(255, 255, 255, 0.72);
  --ink: #1f2430;
  --muted: #5a6070;
  --primary: #0f766e;
  --secondary: #0f4c5c;
  --accent: #c57b29;
  --danger: #bb2c2c;
  --line: rgba(45, 56, 73, 0.14);
  --glass-border: rgba(255, 255, 255, 0.45);
  --bg-radial-a: #f9d29d;
  --bg-radial-b: #9dcfd4;
  --bg-gradient-start: #f6f1e7;
  --bg-gradient-mid: #f0ecdf;
  --bg-gradient-end: #ebe7de;
  --header-a: #0f4c5c;
  --header-b: #0f766e;
  --header-c: #c57b29;
  --orb-a: #f2c181;
  --orb-b: #8dc9cc;
  --btn-passive-bg: rgba(15, 76, 92, 0.1);
  --btn-passive-ink: #203244;
  --table-hover: rgba(15, 118, 110, 0.07);
}

body[data-theme="slate"] {
  --bg: #e8edf3;
  --panel: rgba(255, 255, 255, 0.68);
  --ink: #1a2230;
  --muted: #4f5c70;
  --primary: #315f9f;
  --secondary: #253b5a;
  --accent: #2f809d;
  --danger: #9e2f3e;
  --line: rgba(36, 55, 84, 0.15);
  --glass-border: rgba(255, 255, 255, 0.46);
  --bg-radial-a: #bad2f5;
  --bg-radial-b: #b7e1e1;
  --bg-gradient-start: #edf2f9;
  --bg-gradient-mid: #e6edf6;
  --bg-gradient-end: #dde6f0;
  --header-a: #26364d;
  --header-b: #315f9f;
  --header-c: #2f809d;
  --orb-a: #9ebeea;
  --orb-b: #91c7c8;
  --btn-passive-bg: rgba(49, 95, 159, 0.12);
  --btn-passive-ink: #233247;
  --table-hover: rgba(49, 95, 159, 0.1);
}

body[data-theme="citrus"] {
  --bg: #f8f1dc;
  --panel: rgba(255, 255, 255, 0.76);
  --ink: #2e2a16;
  --muted: #645f41;
  --primary: #3f8f3a;
  --secondary: #27684e;
  --accent: #dc7a2f;
  --danger: #b1452b;
  --line: rgba(77, 85, 52, 0.16);
  --glass-border: rgba(255, 255, 255, 0.5);
  --bg-radial-a: #ffd58a;
  --bg-radial-b: #b4e58f;
  --bg-gradient-start: #fdf6de;
  --bg-gradient-mid: #f7edcf;
  --bg-gradient-end: #f3e6c0;
  --header-a: #27684e;
  --header-b: #3f8f3a;
  --header-c: #dc7a2f;
  --orb-a: #ffc469;
  --orb-b: #9edd6f;
  --btn-passive-bg: rgba(39, 104, 78, 0.12);
  --btn-passive-ink: #2f3720;
  --table-hover: rgba(63, 143, 58, 0.1);
}

body[data-theme="r2b2-caroda"] {
  --bg: #e7eaee;
  --panel: rgba(255, 255, 255, 0.82);
  --ink: #1e3038;
  --muted: #58656d;
  --primary: #1f9bd1;
  --secondary: #2f3137;
  --accent: #f79a2f;
  --danger: #b53b37;
  --line: rgba(35, 46, 56, 0.14);
  --glass-border: rgba(255, 255, 255, 0.58);
  --bg-radial-a: #ffd2a0;
  --bg-radial-b: #a9c1ce;
  --bg-gradient-start: #f2f4f6;
  --bg-gradient-mid: #e8ebef;
  --bg-gradient-end: #dfe4ea;
  --header-a: #0f4252;
  --header-b: #2f3137;
  --header-c: #f79a2f;
  --orb-a: #ffc27d;
  --orb-b: #8fb2c2;
  --btn-passive-bg: rgba(47, 49, 55, 0.1);
  --btn-passive-ink: #1f3943;
  --table-hover: rgba(31, 155, 209, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(1000px 480px at -10% -5%, var(--bg-radial-a) 0%, transparent 72%),
    radial-gradient(700px 450px at 110% 8%, var(--bg-radial-b) 0%, transparent 70%),
    linear-gradient(145deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 52%, var(--bg-gradient-end) 100%);
  color: var(--ink);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(36px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

.bg-orb-a {
  width: 320px;
  height: 320px;
  background: var(--orb-a);
  top: -80px;
  left: -100px;
}

.bg-orb-b {
  width: 360px;
  height: 360px;
  background: var(--orb-b);
  bottom: -110px;
  right: -130px;
}

.app {
  width: min(960px, 93vw);
  margin: 26px auto 34px;
  display: grid;
  gap: 14px;
  position: relative;
  z-index: 2;
}

.app-header {
  background: linear-gradient(130deg, var(--header-a), var(--header-b) 52%, var(--header-c));
  color: #f8fafc;
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: 0 16px 34px rgba(13, 28, 43, 0.24);
  animation: revealUp 0.55s ease-out both;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3.2vw, 2rem);
  font-family: "Fraunces", Georgia, serif;
  letter-spacing: 0.2px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.theme-switch {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 700;
}

.theme-switch select {
  border: 1px solid rgba(248, 250, 252, 0.5);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.2);
  color: #ffffff;
  padding: 8px 10px;
  min-width: 170px;
  font: inherit;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.theme-switch select option {
  color: #111827;
}

.today-label {
  margin: 8px 0 0;
  opacity: 0.98;
  font-weight: 500;
}

.theme-note {
  margin: 8px 0 0;
  opacity: 0.92;
  font-size: 0.92rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.new-day-banner {
  background: linear-gradient(130deg, var(--secondary), var(--primary));
  color: #ffffff;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(13, 28, 43, 0.2);
  animation: revealUp 0.4s ease-out both;
  transition: opacity 0.6s ease;
}

.new-day-banner.is-fading {
  opacity: 0;
}

.is-hidden {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(7px);
  box-shadow:
    0 8px 20px rgba(25, 38, 56, 0.1),
    0 2px 0 rgba(255, 255, 255, 0.5) inset;
  animation: revealUp 0.55s ease-out both;
}

.panel-collapsible {
  padding: 0;
  overflow: hidden;
}

.panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  border-radius: 18px;
  padding: 15px 18px;
  text-align: left;
  color: inherit;
}

.panel-toggle:hover {
  background: rgba(15, 118, 110, 0.06);
}

.panel-toggle-title {
  font-size: 1.08rem;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.panel-toggle-arrow {
  font-size: 0.74rem;
  color: var(--muted);
  transition: transform 0.22s ease;
}

.panel-collapsible.is-open .panel-toggle-arrow {
  transform: rotate(180deg);
}

.panel-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
  overflow: hidden;
}

.panel-collapsible.is-open .panel-body {
  grid-template-rows: 1fr;
}

.panel-body-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 18px;
}

.panel-collapsible.is-open .panel-body-inner {
  padding-bottom: 18px;
}

.panel:nth-of-type(1) {
  animation-delay: 0.08s;
}

.panel:nth-of-type(2) {
  animation-delay: 0.14s;
}

.panel:nth-of-type(3) {
  animation-delay: 0.2s;
}

.panel h2 {
  margin: 0 0 13px;
  font-size: 1.08rem;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 600;
  font-family: "Space Grotesk", sans-serif;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.activity-btn {
  background: var(--btn-passive-bg);
  color: var(--btn-passive-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  font-size: 1.12rem;
  padding: 18px 22px;
  min-height: 64px;
  width: 100%;
}

.activity-btn[data-activity="AYM"] {
  background: rgba(247, 154, 47, 0.14);
  color: #2f3137;
  border: 1px solid rgba(247, 154, 47, 0.28);
}

.activity-btn[data-activity="Caroda"] {
  background: rgba(96, 89, 208, 0.13);
  color: #2f2d63;
  border: 1px solid rgba(96, 89, 208, 0.26);
}

.activity-btn.active {
  background: linear-gradient(130deg, var(--secondary), var(--primary));
  color: #ffffff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--secondary) 48%, transparent);
}

.activity-btn[data-activity="AYM"].active {
  background: linear-gradient(130deg, #3a3c43, #f79a2f);
}

.activity-btn[data-activity="Caroda"].active {
  background: linear-gradient(130deg, #37316b, #5d8dff);
}

.stop-btn {
  background: rgba(187, 44, 44, 0.11);
  color: var(--danger);
  border: 1px solid rgba(187, 44, 44, 0.2);
  display: block;
  width: 100%;
  margin: 0 0 8px;
  min-height: 56px;
  font-size: 1.02rem;
}

.stop-btn:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.active-status {
  margin: 12px 0 4px;
  color: var(--muted);
  font-weight: 500;
}

.active-badge {
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 11px;
  background: color-mix(in srgb, var(--secondary) 12%, #ffffff);
  color: color-mix(in srgb, var(--secondary) 80%, #1f2937);
  font-weight: 600;
  font-size: 0.88rem;
}

.active-badge.is-idle {
  background: rgba(185, 58, 58, 0.1);
  color: #8f2020;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulseDot 1.3s infinite;
}

.active-badge.is-idle .pulse-dot {
  background: #ef4444;
  box-shadow: none;
  animation: none;
}

.session-timer {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.4px;
}

.session-recovery {
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  background: rgba(255, 255, 255, 0.74);
  display: grid;
  gap: 10px;
}

.session-recovery.is-hidden {
  display: none;
}

.session-recovery strong {
  display: block;
  margin-bottom: 4px;
}

.session-recovery p {
  margin: 0;
  color: var(--muted);
}

.recovery-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.recovery-btn {
  width: auto;
  min-height: 40px;
  border-radius: 10px;
}

.recovery-btn.keep,
.secondary-btn,
.manual-cancel-btn {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  color: var(--ink);
}

.recovery-btn.stop {
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary);
  border: 1px solid rgba(15, 118, 110, 0.2);
}

.recovery-btn.discard {
  background: rgba(187, 44, 44, 0.11);
  color: var(--danger);
  border: 1px solid rgba(187, 44, 44, 0.18);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
}

.card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px;
}

.card p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.card strong {
  font-size: 1.25rem;
}

.overall {
  margin: 14px 0 0;
  color: #203244;
  font-weight: 500;
}

.export-btn {
  margin-top: 12px;
  width: 100%;
  min-height: 52px;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--secondary), var(--primary));
  color: #ffffff;
  letter-spacing: 0.2px;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.manual-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.manual-grid input,
.manual-grid select {
  width: 100%;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}

.manual-add-btn {
  margin-top: 12px;
  width: 100%;
  min-height: 46px;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--secondary), var(--primary));
  color: #ffffff;
}

.manual-mode-hint,
.data-tools-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.manual-actions,
.data-tools-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.manual-cancel-btn,
.secondary-btn {
  min-height: 46px;
  border-radius: 10px;
  width: auto;
}

.data-tools-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
}

.data-tools-status.error {
  color: #a91d1d;
}

.data-tools-status.success {
  color: #0f7a45;
}

.manual-status {
  min-height: 20px;
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.manual-status.error {
  color: #a91d1d;
}

.manual-status.success {
  color: #0f7a45;
}

.entries-toggle-btn {
  margin-top: 10px;
  width: 100%;
  min-height: 38px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted, #888);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.entries-toggle-btn:hover {
  background: var(--glass-border);
  color: var(--text);
}

.entries-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  align-items: end;
}

.entries-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.entries-filters input,
.entries-filters select {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}

.entries-scope {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.entries-scope-btn {
  width: auto;
  min-height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  color: var(--ink);
}

.entries-scope-btn.active {
  background: linear-gradient(120deg, var(--secondary), var(--primary));
  color: #ffffff;
}

.entries-unusual-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-bottom: 6px;
}

.entries-unusual-toggle input {
  min-height: auto;
  width: 16px;
  height: 16px;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

th {
  color: #3e495d;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.78);
}

th:last-child,
td:last-child {
  text-align: center;
}

.empty {
  color: var(--muted);
}

tbody tr {
  transition: background-color 0.18s ease;
}

tbody tr:hover {
  background: var(--table-hover);
}

.entry-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.entry-activity-cell {
  min-width: 200px;
}

.entry-activity-name {
  font-weight: 600;
}

.entry-flags {
  margin-top: 6px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.entry-flag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.entry-flag--manual,
.entry-flag--edited {
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
}

.entry-flag--short {
  background: rgba(217, 119, 6, 0.13);
  color: #b45309;
}

.entry-flag--long {
  background: rgba(8, 145, 178, 0.13);
  color: #0f766e;
}

.entry-row--manual td:first-child,
.entry-row--edited td:first-child {
  box-shadow: inset 4px 0 0 rgba(124, 58, 237, 0.5);
}

.entry-row--short td:first-child {
  box-shadow: inset 4px 0 0 rgba(217, 119, 6, 0.5);
}

.entry-row--long td:first-child {
  box-shadow: inset 4px 0 0 rgba(8, 145, 178, 0.5);
}

.entry-action-btn {
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 0.79rem;
  min-height: 30px;
  width: auto;
  transform: none;
}

.entry-action-btn:hover {
  transform: none;
}

.entry-action-btn.edit {
  background: rgba(37, 99, 235, 0.13);
  color: #1e40af;
}

.entry-action-btn.delete {
  background: rgba(185, 58, 58, 0.14);
  color: #9f1d1d;
}

.app-footer {
  width: min(960px, 93vw);
  margin: 0 auto 26px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 22, 0.45);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 16px;
}

.confirm-overlay.is-hidden {
  display: none;
}

.confirm-modal {
  width: min(440px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 42px rgba(20, 30, 44, 0.24);
  padding: 16px;
}

.confirm-modal h3 {
  margin: 0 0 8px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.1rem;
}

.confirm-modal p {
  margin: 0;
  color: var(--muted);
}

.confirm-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-btn {
  min-height: 38px;
  border-radius: 10px;
  width: auto;
}

.confirm-btn.cancel {
  background: #eef1f5;
  color: #223045;
}

.confirm-btn.ok {
  background: linear-gradient(120deg, var(--secondary), var(--primary));
  color: #ffffff;
}

@keyframes pulseDot {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  }

  70% {
    box-shadow: 0 0 0 9px rgba(34, 197, 94, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .app {
    margin-top: 16px;
    margin-bottom: 22px;
  }

  .app-header,
  .panel {
    border-radius: 14px;
  }

  .header-top {
    flex-direction: column;
    align-items: stretch;
  }

  .theme-switch select {
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .manual-grid {
    grid-template-columns: 1fr;
  }

  .manual-actions,
  .data-tools-actions,
  .recovery-actions,
  .entries-scope {
    flex-direction: column;
  }

  .entries-filters {
    grid-template-columns: 1fr;
  }

  .sync-actions {
    grid-template-columns: 1fr;
  }

  .buttons {
    grid-template-columns: 1fr;
  }

  .session-timer {
    font-size: 1.5rem;
  }

  button {
    width: 100%;
    justify-content: center;
  }

  .stop-btn {
    width: 100%;
  }

  .entry-actions {
    justify-content: center;
  }

  .manual-cancel-btn,
  .secondary-btn,
  .recovery-btn {
    width: 100%;
  }

  .app-footer {
    width: min(960px, 93vw);
    text-align: left;
    margin-bottom: 18px;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .confirm-btn {
    width: 100%;
  }
}
