:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-input: #0d1117;
  --border: #30363d;
  --border-strong: #484f58;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #4493f8;
  --accent-hover: #1f6feb;
  --ok: #3fb950;
  --err: #f85149;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 0;
  color: var(--text);
  line-height: 1.5;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}
h1 { font-size: 1.4rem; margin: 0; color: var(--text); }
h2 { color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.field { display: block; margin: 1rem 0; }
.field > span { display: block; font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.field select, .field input {
  width: 100%;
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
}
.field select:focus, .field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(68, 147, 248, 0.25);
}
.field input::placeholder { color: var(--text-dim); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(0.7); cursor: pointer; }
.hint { font-size: 0.85rem; color: var(--text-dim); }
.picker-row { display: flex; align-items: center; gap: 0.75rem; }
.folder-name { color: var(--text-dim); font-size: 0.95rem; }
.folder-name.selected { color: var(--ok); }
.folder-name.selected::before { content: "✓ "; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 8rem; }
.checkbox { display: flex; align-items: center; gap: 0.5rem; margin: 1rem 0; color: var(--text); }
.checkbox input[type="checkbox"] { accent-color: var(--accent); }
.actions { display: flex; gap: 0.75rem; align-items: center; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: #21262d; border-color: var(--text-muted); }
.link-btn {
  background: none; border: none; color: var(--err); cursor: pointer;
  font-size: 0.85rem; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

#progress-section { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.summary { font-size: 1rem; margin-bottom: 0.5rem; color: var(--text); }
.log {
  list-style: none; padding: 0; margin: 0;
  max-height: 50vh; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.log li { padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border); color: var(--text); }
.log li:last-child { border-bottom: none; }
.log .ok { color: var(--ok); }
.log .err { color: var(--err); }
.log .muted { color: var(--text-muted); }
.log code { background: #1f2937; color: var(--text); padding: 0.05rem 0.3rem; border-radius: 3px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ── DateRangePicker ────────────────────────────────── */
.drp-wrap { position: relative; display: inline-block; }

.drp-trigger { cursor: pointer; }
.date-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 0.9rem;
  user-select: none;
}
.date-filter:hover { border-color: var(--border-strong); }
.date-filter .range { display: flex; align-items: center; gap: 4px; }
.date-filter .start-date, .date-filter .end-date { font-weight: 600; color: var(--accent); }
.date-filter .toggle { font-size: 1rem; }

/* Popover shell */
.date-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: flex;
  width: 420px;
  height: 402px;
  background-color: #eeeeee;
  border-radius: 16px;
  box-shadow: rgba(0,0,0,0.35) 0px 3px 16px 0px;
  font-size: 14px;
  color: #333333;
  z-index: 1000;
  overflow: hidden;
}

/* Left panel */
.drp-left {
  width: 256px;
  min-width: 256px;
  height: 402px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.weekdays { display: block; width: 256px; background: #e0e0e0; padding: 4px 0 2px; flex-shrink: 0; }
.header-cell {
  display: block;
  float: left;
  width: 30px;
  height: 20px;
  font-size: 9px;
  text-align: center;
  line-height: 20px;
  color: #555;
  font-weight: 700;
}
.header-cell.month { width: 32px; }
.header-cell.weekend { color: #999; }

.days-container {
  width: 256px;
  height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}
.days-container::-webkit-scrollbar { width: 6px; }
.days-container::-webkit-scrollbar-track { background: #e0e0e0; }
.days-container::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }

.tse-content { width: 256px; }

.week { display: block; float: left; width: 256px; height: 32px; clear: both; }

.month-label-cell {
  display: block;
  float: left;
  width: 32px;
  height: 32px;
  font-size: 8px;
  color: #888;
  text-align: center;
  line-height: 16px;
  padding-top: 2px;
  overflow: hidden;
}
.month-name { display: block; font-weight: 700; font-size: 8px; color: #666; line-height: 16px; }

.day {
  display: block;
  float: left;
  width: 30px;
  height: 30px;
  padding: 6px 0 0;
  font-size: 13px;
  text-align: center;
  position: relative;
  cursor: pointer;
  color: #333;
  border-radius: 50%;
  margin: 1px 0;
  line-height: 1;
}
.day:hover { background: #cdd8f8; }

.adjust-left, .adjust-right {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  pointer-events: none;
}
.adjust-left  { left: 0; }
.adjust-right { right: 0; }

.day.inrange   { background: #b0c1f6; color: #17379a; font-weight: 700; border-radius: 0; }
.day.inrange .adjust-left, .day.inrange .adjust-right { background: #b0c1f6; }
.day.pos-start { background: #5b8af5; color: #fff; font-weight: 700; border-radius: 50% 0 0 50%; }
.day.pos-start .adjust-right { background: #b0c1f6; }
.day.pos-end   { background: #5b8af5; color: #fff; font-weight: 700; border-radius: 0 50% 50% 0; }
.day.pos-end .adjust-left { background: #b0c1f6; }
.day.pos-start.pos-end { border-radius: 50%; }
.day.pos-start.pos-end .adjust-left, .day.pos-start.pos-end .adjust-right { background: transparent; }

.day.today::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  background: #777;
  border-radius: 50%;
  margin: 1px auto 0;
}

/* Right panel */
.drp-right {
  flex: 1;
  background: #f1f1f1;
  border-radius: 0 16px 16px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.predefined {
  background: #ffffff;
  border-radius: 0 16px 0 0;
  padding: 10px 0 8px;
  flex-shrink: 0;
}
.predefined ul { list-style: none; padding: 0; margin: 0; }
.predefined li { display: flex; justify-content: center; }

.range-button {
  display: block;
  width: 104px;
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  background-color: #e8e8e8;
  color: #2f3137;
  border: 1px solid #bcc4ca;
  border-radius: 4px;
  cursor: pointer;
  margin: 2px auto;
  text-align: center;
}
.range-button:hover { background-color: #537dec; color: #fff; border-color: #1844cc; }

.drp-inputs {
  padding: 10px 12px 8px;
  background: #fafafa;
  flex: 1;
}
.drp-inputs p { margin: 4px 0; }
.drp-inputs h4 { margin: 6px 0 2px; font-size: 12px; color: #555; }

.date {
  width: 120px;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 3px;
  text-align: center;
  background: #fff;
}

.apply-button {
  display: inline-block;
  width: 110px;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
  background-color: #537dec;
  color: #ffffff;
  border: 1px solid #1844cc;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 6px;
}
.apply-button:hover { background-color: #3a62d4; }
