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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.5;
}

/* Modal Styles */
.modal {
  display: flex;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
}

.modal-content h2 {
  margin-bottom: 10px;
  color: #333;
  font-size: 1.5rem;
}

.modal-content > p {
  margin-bottom: 20px;
  color: #666;
  font-size: 0.9rem;
}

.modal-content .setup-error {
  padding: 10px;
  border-left: 3px solid #b42318;
  background: #fef3f2;
  color: #912018;
  overflow-wrap: anywhere;
}

.modal-content .setup-success {
  padding: 10px;
  border-left: 3px solid #15803d;
  background: #f0fdf4;
  color: #166534;
  overflow-wrap: anywhere;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.modal-content label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-content input {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: monospace;
}

.modal-content input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.modal-buttons button {
  flex: 1;
}

.modal-content .help-text {
  font-size: 0.75rem;
  color: #888;
  margin-top: 10px;
}

.modal-content a {
  color: #007bff;
  text-decoration: none;
}

.modal-content a:hover {
  text-decoration: underline;
}

.container {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
  background: white;
}

.squirrel-trail-decor {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 15;
}

.squirrel-print-fragment {
  position: absolute;
  width: 18px;
  height: 72px;
  color: #725238;
  opacity: 0.3;
  font-size: 1rem;
  line-height: 1;
  user-select: none;
}

.squirrel-print-fragment.is-left {
  left: 1px;
}

.squirrel-print-fragment.is-right {
  right: 1px;
}

.squirrel-print-fragment span {
  position: absolute;
  left: var(--print-offset);
  top: calc(var(--print-index) * 21px);
  transform: rotate(var(--print-angle));
}

/* Header Section */
header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #999;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.brand-lockup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-bottom: 5px;
}

.brand-lockup h1 {
  margin: 0;
}

.squirrel-trail-graphic {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 118px;
  height: 38px;
  overflow: hidden;
  color: #6f4c2f;
  user-select: none;
}

.trail-squirrel {
  font-size: 1.75rem;
  line-height: 1;
}

.trail-print {
  display: inline-block;
  font-size: 0.8rem;
  opacity: 0.72;
}

.trail-print.print-one {
  transform: translateY(6px) rotate(-24deg);
}

.trail-print.print-two {
  transform: translateY(-4px) rotate(18deg);
}

.trail-print.print-three {
  transform: translateY(5px) rotate(-18deg);
}

header h1 {
  font-size: 1.3rem;
  font-weight: bold;
  margin-bottom: 5px;
  color: #333;
}

header .subtitle {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.4;
  margin-bottom: 8px;
}

.header-form {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.85rem;
}

.header-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.form-value {
  font-weight: normal;
  min-width: 20px;
}

.session-date-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

#dateInput.is-other-day {
  border: 2px solid #b45309;
  background-color: #fff3cd;
  color: #713f12;
}

.date-warning {
  padding: 4px 6px;
  border-left: 3px solid #b45309;
  background-color: #fff3cd;
  color: #713f12;
  font-size: 0.8rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sync-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
  color: #166534;
  font-size: 0.85rem;
}

.sync-status-icon {
  font-size: 1rem;
  line-height: 1;
}

.sync-last-sync {
  margin: 0;
  color: #888;
  font-size: 0.75rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.sync-status[data-state="local-only"],
.sync-status[data-state="offline"],
.sync-status[data-state="sign-in"],
.sync-status[data-state="paused"] {
  color: #c2410c;
  font-weight: 800;
}

.sync-status[data-state="connected"],
.sync-status[data-state="synced"] {
  color: #15803d;
}

.sync-status[data-state="syncing"] {
  color: #0f766e;
}

.audio-enable-button {
  min-height: 36px;
  font-size: 0.85rem;
  font-weight: 700;
}

.form-input-small {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 2px;
  font-size: 0.85rem;
  font-family: Arial, sans-serif;
}

.form-input-small[type="time"],
.form-input-small[type="date"] {
  padding: 4px 8px;
}

header .help-text {
  font-size: 0.8rem;
  color: #888;
}

header a {
  color: #0066cc;
  text-decoration: none;
}

header a:hover {
  text-decoration: underline;
}

/* Timer Widget */
.timer-widget {
  width: 100%;
  max-width: 100%;
  margin-top: 10px;
  min-inline-size: 0;
  padding: 7px 10px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  text-align: left;
}

.timer-widget legend {
  padding: 0 6px;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 600;
}

.reminder-settings {
  display: contents;
  font-size: 0.8rem;
}

.reminder-settings label {
  display: flex;
  align-items: center;
  gap: 5px;
}

#reminderMinutesInput {
  width: 50px;
  padding: 3px;
}

.bell-volume-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
}

#bellVolumeInput {
  width: 100px;
}

#bellVolumeValue {
  width: 4ch;
  font-variant-numeric: tabular-nums;
}

.timer-display-small {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.reminder-label {
  font-size: 0.8rem;
  font-weight: 600;
}

.time-small {
  font-size: 1rem;
  font-weight: bold;
  font-family: "Courier New", monospace;
  color: #333;
  min-width: 5ch;
  font-variant-numeric: tabular-nums;
}

.controls-small {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.btn-small {
  padding: 4px 8px;
  border: 1px solid #999;
  background-color: #f5f5f5;
  border-radius: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-small:hover:not(:disabled) {
  background-color: #e0e0e0;
}

.btn-small:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-small.btn-primary {
  background-color: #007bff;
  color: white;
  border-color: #0056b3;
}

.btn-small.btn-primary:hover:not(:disabled) {
  background-color: #0056b3;
}

.btn-small.btn-secondary {
  background-color: #6c757d;
  color: white;
  border-color: #545b62;
}

.btn-small.btn-secondary:hover:not(:disabled) {
  background-color: #545b62;
}

.btn-small.btn-tertiary {
  background-color: #28a745;
  color: white;
  border-color: #1e7e34;
}

.btn-small.btn-tertiary:hover:not(:disabled) {
  background-color: #1e7e34;
}

/* Grid Controls */
.grid-controls {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.task-input-wrapper {
  display: flex;
  gap: 6px;
}

.task-reuse-wrapper {
  display: flex;
  gap: 6px;
  max-width: 100%;
}

.task-reuse-wrapper select {
  min-width: 0;
}

.input-field-small {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 2px;
  font-size: 0.85rem;
  width: 180px;
}

.input-field-small:focus {
  outline: none;
  border-color: #007bff;
}

.spacer {
  flex: 1;
}

.advanced-actions {
  max-width: 100%;
}

.advanced-actions summary {
  padding: 6px 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.advanced-actions summary:focus-visible {
  outline: 2px solid #007bff;
}

.advanced-controls,
.data-change-actions,
.export-actions,
.account-actions:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 10px;
}

.advanced-controls {
  flex-wrap: wrap;
  margin-top: 8px;
}

.data-change-actions {
  flex-wrap: wrap;
}

.action-separator {
  color: #777;
}

.btn {
  padding: 6px 12px;
  border: 1px solid #999;
  background-color: #f5f5f5;
  border-radius: 2px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
  background-color: #e0e0e0;
}

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

.btn-primary {
  background-color: #007bff;
  color: white;
  border-color: #0056b3;
}

.btn-primary:hover:not(:disabled) {
  background-color: #0056b3;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
  border-color: #545b62;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #545b62;
}

.btn-tertiary {
  background-color: #28a745;
  color: white;
  border-color: #1e7e34;
}

.btn-tertiary:hover:not(:disabled) {
  background-color: #1e7e34;
}

.btn-danger {
  background-color: #dc3545;
  color: white;
  border-color: #bd2130;
}

.btn-danger:hover:not(:disabled) {
  background-color: #bd2130;
}

.delete-task-details {
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.delete-task-details dt {
  font-weight: 600;
  margin-top: 8px;
}

.delete-task-details dd {
  margin: 2px 0 0;
}

.delete-task-details ul {
  margin: 2px 0 0;
  padding-left: 20px;
}

.remote-notice {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 900;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  background: #fff8e1;
  border: 1px solid #f0c36d;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 0.9rem;
}

.remote-notice[hidden] {
  display: none;
}

.remote-notice ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.remote-notice-dismiss {
  border: none;
  background: none;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* Grid Section */
.auto-center-status:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

#autoCenterCountdown {
  display: inline-block;
  min-width: 4ch;
  font-variant-numeric: tabular-nums;
}

.grid-section {
  background: white;
  border: 1px solid #ccc;
  margin-bottom: 15px;
  overflow-x: auto;
}

.grid-container {
  position: relative;
  overflow-x: auto;
  border: 1px solid #ddd;
}

.current-time-line {
  position: absolute;
  width: 2px;
  background: #c62828;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 5;
}

.current-time-line::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #c62828;
}

/* Table Styling */
.time-grid {
  width: 100%;
  min-width: 2868px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.7rem;
}

.task-grid-column {
  width: 180px;
}

.interval-grid-column {
  width: 28px;
}

.time-grid thead {
  background-color: #f9f9f9;
  border-bottom: 2px solid #999;
}

.time-grid th {
  padding: 4px 2px;
  text-align: center;
  font-weight: 600;
  border: 1px solid #ccc;
  background-color: #f9f9f9;
}

.time-grid .task-column {
  width: 100px;
  text-align: left;
  font-weight: 600;
  padding: 6px 4px;
  position: sticky;
  left: 0;
  z-index: 10;
  background-color: #f9f9f9;
  border-right: 2px solid #999;
}

.time-grid .hour-label {
  font-weight: 700;
  font-size: 0.8rem;
  background-color: #f0f0f0;
  padding: 4px 2px;
  border-bottom: 1px solid #999;
}

.time-grid .interval-header {
  background-color: #ffffff;
  border-bottom: 1px solid #ccc;
}

.time-grid .interval-number {
  padding: 2px 1px;
  font-size: 0.6rem;
  color: #999;
  font-weight: normal;
}

/* Table Body */
.time-grid tbody tr {
  border-bottom: 1px solid #ddd;
  height: 28px;
}

.time-grid tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

.time-grid tbody tr:nth-child(even) {
  background-color: #fafafa;
}

.time-grid tbody td {
  border: 1px solid #ddd;
  padding: 2px;
  text-align: center;
  vertical-align: middle;
}

/* Zebra striping - alternate every 4 columns (hours) */
.time-grid tbody td:nth-child(4n + 2),
.time-grid tbody td:nth-child(4n + 3),
.time-grid tbody td:nth-child(4n + 4),
.time-grid tbody td:nth-child(4n + 5) {
  background-color: #ffffff;
}

.time-grid tbody td:nth-child(8n + 6),
.time-grid tbody td:nth-child(8n + 7),
.time-grid tbody td:nth-child(8n + 8),
.time-grid tbody td:nth-child(8n + 9) {
  background-color: #f5f5f5;
}

/* Task name cell */
.time-grid .task-name-cell {
  position: sticky;
  left: 0;
  z-index: 10;
  padding: 6px 4px;
  font-weight: 500;
  background-color: #ffffff;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.8rem;
  border-right: 2px solid #999;
}

.time-grid tbody tr:nth-child(even) .task-name-cell {
  background-color: #fafafa;
}

.time-grid .task-name-cell:hover {
  background-color: #fffacd;
}

.task-name-button,
.task-name-editor {
  display: inline-block;
  width: calc(100% - 20px);
  min-width: 0;
  vertical-align: middle;
  font: inherit;
  text-align: left;
}

.task-name-button {
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: inherit;
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-name-button:hover {
  text-decoration: underline;
}

.task-name-button:focus-visible {
  outline: 2px solid #007bff;
}

.task-name-editor {
  padding: 1px 2px;
  border: 1px solid #007bff;
  background: white;
}

.time-grid .task-remove {
  cursor: pointer;
  color: #dc3545;
  font-weight: bold;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.time-grid tbody tr:hover .task-remove {
  opacity: 1;
}

.time-grid .task-remove:hover {
  color: #a02830;
}

/* Interval Circles/Bubbles */
.interval-bubble {
  width: 16px;
  height: 16px;
  border: 1px solid #999;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: #ffffff;
  transition: all 0.15s ease;
  font-size: 0;
}

.interval-bubble:hover {
  background-color: #ffe0e0;
  border-color: #666;
}

.interval-bubble.filled {
  background-color: #333;
  border-color: #333;
}

.interval-bubble.filled:hover {
  background-color: #555;
  border-color: #555;
}

/* Notes & Summary Section */
.notes-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  border: 1px solid #ccc;
  padding: 15px;
  background-color: #f9f9f9;
}

.notes-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 4px;
}

.notes-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.notes-right {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.notes-textarea {
  flex: 1;
  min-height: 100px;
  padding: 8px;
  border: 1px solid #ccc;
  font-size: 0.8rem;
  font-family: Arial, sans-serif;
  resize: vertical;
}

.notes-textarea:focus {
  outline: none;
  border-color: #007bff;
  background-color: #fffacd;
}

.summary-content {
  flex: 1;
  overflow: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.75rem;
}

.summary-table th,
.summary-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #ddd;
  text-align: right;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

.summary-table th:first-child {
  text-align: left;
  overflow-wrap: anywhere;
}

.summary-table th:nth-child(2) {
  width: 5rem;
}

.summary-table th:nth-child(3) {
  width: 6rem;
}

.summary-table tbody th {
  font-weight: normal;
}

.summary-table td:not([colspan]) {
  white-space: nowrap;
}

.summary-table .summary-header th,
.summary-table .summary-header td {
  font-weight: 700;
  background-color: #eee;
  border-bottom: 2px solid #bbb;
}

.summary-table .summary-empty {
  color: #777;
  font-style: italic;
  text-align: center;
}

/* Footer */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  text-align: left;
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid #ccc;
  font-size: 0.7rem;
  color: #888;
}

footer p {
  margin: 0;
}

footer a {
  color: #0066cc;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 900px) {
  .notes-section {
    grid-template-columns: 1fr;
  }

  .header-form {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .grid-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .task-input-wrapper {
    width: 100%;
  }

  .input-field-small {
    width: 100%;
  }

  .spacer {
    display: none;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 10px;
  }

  header h1 {
    font-size: 1.1rem;
  }

  .time-grid {
    font-size: 0.6rem;
  }

  .time-grid .task-column {
    width: 70px;
  }

  .time-grid .task-name-cell {
    font-size: 0.7rem;
  }

  .interval-bubble {
    width: 12px;
    height: 12px;
  }

  footer {
    justify-content: center;
    text-align: center;
  }

  footer > * {
    flex: 1 1 100%;
  }
}
