html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  background: #fff;
}

#root {
  height: 100dvh; /* account for mobile browser chrome */
  min-height: 100vh; /* fallback */
  width: 100vw;
}

.container {
  height: 100%;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: visible;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: #fff;
  color: #000;
  padding: 40px clamp(80px, 12vw, 200px) 0;
}

.session-id {
  font-family: inherit;
  font-size: 10px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #000;
  padding: 4px;
}

.counter-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
}

.counter-row > h1 {
  margin: 0;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  border: 1px solid #000;
  border-bottom: none;
  background: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid #000;
}

.card {
  border: 1px solid #000;
  border-right: none;
  border-bottom: none;
  padding: 16px;
  background: #fff;
}

.card:nth-child(3n) {
  border-right: 1px solid #000;
}

.card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f5f5f5;
  display: block;
  margin-bottom: 12px;
  border: 1px solid #000;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-desc {
  font-size: 12px;
  margin: 0 0 12px 0;
  color: #000;
  line-height: 1.5;
}

.counter-value {
  margin: 0;
  padding: 24px;
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  line-height: 1;
  font-size: clamp(40px, 14vw, 88px);
  letter-spacing: -2px;
  white-space: nowrap;
  overflow: hidden;
  color: #000;
  border: 1px solid #000;
  background: #fff;
  text-align: center;
}

.increment-btn {
  flex: 0 0 auto;
  width: clamp(120px, 30vw, 240px);
  align-self: stretch;
  margin-left: 0;
  border: 1px solid #000;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #000;
  background: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: none;
}

.increment-btn:hover {
  background: #000;
  color: #fff;
}

.increment-btn:active {
  background: #333;
}

.btn {
  display: inline-block;
  border: 1px solid #000;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  color: #000;
  background: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: none;
  margin-right: 6px;
  margin-bottom: 4px;
}

.btn:hover {
  background: #000;
  color: #fff;
}

.btn:active {
  background: #333;
}

.btn:focus-visible {
  outline: 1px solid #000;
  outline-offset: 2px;
}

.btn-favorite.is-active {
  background: #000;
  color: #fff;
}


.btn-danger:hover {
  background: #000;
  color: #fff;
}

.tab-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  gap: 0;
  position: relative;
}

.tab-bar {
  display: flex;
  gap: 8px;
  padding: 0 8px; /* space so first/last tab shadows are visible */
  background: transparent;
  flex-shrink: 0;
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 8px 16px;
  border: 1px solid #000;
  border-bottom: none;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: none;
  box-shadow: 4px -4px 0 0 #ccc;
  white-space: nowrap;
  margin-right: 8px;
  min-width: 0;
}

.tab-button:hover {
  background: #f5f5f5;
}

.tab-button.active {
  background: #000;
  color: #fff;
  border-bottom: 1px solid #fff;
  position: relative;
  font-weight: 700;
  box-shadow: 4px -4px 0 0 #666;
}

.tab-button:active {
  background: #f5f5f5;
}

.tab-content-wrapper {
  flex: 1;
  min-height: 0;
  max-height: calc(100% - 40px);
  overflow: hidden; /* clip child overflow so nothing shows above container */
  border: 1px solid #000;
  background: #fff;
  box-shadow: 4px -4px 0 0 #ccc;
  margin-bottom: 40px;
}

.tab-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  padding-bottom: 120px; /* extra breathing room at bottom */
  scroll-padding-bottom: 120px; /* ensure last content not cut off */
  overflow-y: auto;
  overscroll-behavior: contain; /* prevent overscroll bounce showing outside */
  -webkit-overflow-scrolling: touch;
}

/* extra bottom spacer to ensure last element + shadows are fully visible */
.tab-content::after {
  content: "";
  flex: 0 0 120px;
}

/* Headings within tab content */
.tab-content h1 {
  margin: 0;
  padding: 0;
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #000;
  padding-bottom: 12px;
}

.tab-content h2 {
  margin: 12px 0 8px 0;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
}

.tab-content p {
  margin: 0 0 8px 0;
  line-height: 1.6;
}

.tab-content p:last-of-type {
  margin-bottom: 0;
}

/* Style all button elements consistently */
button {
  font-family: inherit;
  border: 1px solid #000;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: #000;
  background: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: none;
  margin-right: 6px;
}

button:hover {
  background: #000;
  color: #fff;
}

button:active {
  background: #333;
}

button:focus-visible {
  outline: 1px solid #000;
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

button:disabled:hover {
  background: #fff;
  color: #000;
}

/* Counter and Clock widgets */
.counter-widget {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid #000;
  background: #fff;
}

.clock-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border: 1px solid #000;
  background: #fff;
}

.counter-display,
.clock-display {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
  padding: 16px 24px;
  background: #fff;
  min-width: 100px;
  text-align: center;
}

.counter-widget > button {
  margin: 0;
  padding: 16px 20px;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Component wrapper and code snippets */
.component-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.code-snippet-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  display: block;
  overflow: visible;
}

.code-snippet-wrapper pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  overflow: visible;
  box-sizing: border-box;
}

.code-snippet-wrapper code {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
}

.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  padding: 4px 8px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  z-index: 10;
  background: #fff;
  border: 1px solid #000;
  cursor: pointer;
}

.copy-button:hover {
  background: #000;
  color: #fff;
}

/* Message Console */
.message-console {
  display: flex;
  flex-direction: column;
  border: 1px solid #000;
  background: #fafafa;
  height: 180px;
  flex-shrink: 0;
  margin-top: 12px;
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #000;
  color: #fff;
  border-bottom: 1px solid #000;
}

.console-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.console-clear-btn {
  margin: 0;
  padding: 3px 8px;
  font-size: 8px;
  background: #fff;
  color: #000;
  border: 1px solid #fff;
}

.console-clear-btn:hover {
  background: #f5f5f5;
  color: #000;
  border: 1px solid #ccc;
}

.console-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 10px;
  line-height: 1.4;
  scroll-behavior: smooth;
}

.console-empty {
  color: #999;
  font-style: italic;
  padding: 4px;
}

.console-message {
  padding: 2px 0;
  word-break: break-all;
}

.console-timestamp {
  color: #666;
  margin-right: 8px;
  font-weight: 600;
}

.console-data {
  color: #000;
}

.console-formatted {
  color: #0066cc;
  font-weight: 600;
  white-space: pre;
}

/* Mobile styles */
@media (max-width: 768px) {
  html, body {
    font-size: 16px;
    overflow-x: hidden;
    width: 100%;
  }

  .container {
    padding: 20px 12px 0;
    max-width: 100%;
    overflow-x: hidden;
  }

  .tab-view {
    overflow-x: hidden;
  }

  .tab-content-wrapper {
    margin-bottom: 20px;
    overflow-x: hidden;
    border-top: 1px solid #000;
    margin-top: 0;
  }

  .tab-content {
    padding: 12px;
    gap: 8px;
    overflow-x: hidden;
  }

  .component-wrapper {
    overflow: visible;
    display: flex;
    flex-direction: column;
  }

  .tab-content p {
    font-size: 16px;
    line-height: 1.6;
    margin: 0 0 8px 0;
  }

  .tab-content h1 {
    font-size: 22px;
    margin: 0;
    padding: 0 0 8px 0;
  }

  .tab-content h2 {
    font-size: 14px;
    margin: 8px 0 6px 0;
  }

  .counter-display,
  .clock-display {
    font-size: 56px;
  }

  .counter-widget {
    padding: 12px;
    gap: 12px;
  }

  button {
    font-size: 14px;
    padding: 10px 16px;
    min-height: 44px;
    margin-right: 4px;
  }

  .tab-bar {
    gap: 4px;
    margin-bottom: 0;
    flex-wrap: nowrap;
    overflow-x: hidden; /* avoid horizontal scrollbar on mobile */
    align-items: center;
    justify-content: space-between; /* spread tabs to fit width */
  }

  .tab-button {
    font-size: 10px;          /* smaller label */
    padding: 6px 8px;         /* tighter padding */
    letter-spacing: 0.2px;    /* reduce width from tracking */
    box-shadow: 2px -2px 0 0 #ccc;
    flex: 1 1 0;              /* allow buttons to shrink to fit */
    min-width: 0;             /* enable flex shrink below content size */
  }

  .tab-button.active {
    box-shadow: 2px -2px 0 0 #666;
    border-bottom: 1px solid #000;
    margin-bottom: -1px;
  }

  .console-timestamp {
    font-size: 11px;
  }

  .console-data {
    font-size: 11px;
  }

  .console-title {
    font-size: 11px;
  }

  .console-header {
    padding: 6px 10px;
  }

  .console-content {
    padding: 6px;
    overflow-x: auto;
  }

  .console-message {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .console-data {
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
  }

  .console-formatted {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
  }

  .copy-button {
    font-size: 11px;
    padding: 6px 10px;
  }

  /* Syntax highlighter code - static block with wrapping */
  .code-snippet-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    box-sizing: border-box !important;
  }

  .code-snippet-wrapper * {
    visibility: visible !important;
    opacity: 1 !important;
    box-sizing: border-box !important;
  }

  .code-snippet-wrapper > div,
  .code-snippet-wrapper > div > pre {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    overflow: visible !important;
  }

  .code-snippet-wrapper code {
    font-size: 12px !important;
    visibility: visible !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }

  .code-snippet-wrapper pre {
    padding: 10px !important;
    margin: 0 !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    visibility: visible !important;
    background: #fafafa !important;
    border: 1px solid #000 !important;
    min-height: 50px !important;
    box-sizing: border-box !important;
  }

  .code-snippet-wrapper pre code {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }

  /* Card list for mobile */
  .card-list {
    grid-template-columns: 1fr;
  }

  .card:nth-child(3n) {
    border-right: none;
  }

  .card {
    border-right: 1px solid #000;
  }

  /* Message console width constraints */
  .message-console {
    max-width: 100%;
    overflow: hidden;
  }

  /* Reduce counter widget margins */
  .counter-row {
    gap: 0;
  }
}
