:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --green: #4ade80;
  --gray: #64748b;
  --blue: #60a5fa;
  --yellow: #fbbf24;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Setup banner */
#setup-banner {
  background: #4c1d95;
  color: #ede9fe;
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

/* Header */
header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

#clock {
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

#open-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 6px;
  padding: 14px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-bar button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.tab-bar button:hover {
  background: var(--border);
  color: var(--text);
}

.tab-bar button.active {
  background: var(--green);
  border-color: var(--green);
  color: #0f172a;
  font-weight: 600;
}

/* Main */
main {
  flex: 1;
  padding: 16px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

@media (min-width: 480px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
  }
}

@media (min-width: 768px) {
  main {
    padding: 20px;
  }
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
  }
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card.open {
  border-color: rgba(74, 222, 128, 0.35);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.08);
}

.card.closed {
  opacity: 0.72;
}

.card[hidden] {
  display: none;
}

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

.card-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.card-category {
  font-size: 10px;
  padding: 2px 7px;
  background: #1e3a5f;
  border-radius: 20px;
  color: #93c5fd;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Status section */
.card-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge {
  font-size: 13px;
  font-weight: 700;
}

.badge.open  { color: var(--green); }
.badge.closed { color: var(--gray); font-weight: 600; }
.badge.loading { color: var(--text-muted); font-weight: 400; }
.badge.error { color: var(--gray); font-weight: 400; }
.badge.unknown { color: var(--text-muted); font-weight: 400; }
.badge.temporarily-closed { color: var(--yellow); font-weight: 600; }
.badge.permanently-closed { color: #ef4444; font-weight: 600; }

.sub-info {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.sub-info.next-open {
  color: var(--blue);
}

/* Memo */
.card-memo {
  font-size: 11px;
  color: var(--gray);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  line-height: 1.4;
}

/* Empty state */
#empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 14px;
  line-height: 2;
}

/* Footer */
footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#last-updated {
  font-size: 12px;
  color: var(--text-muted);
}

#refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

#refresh-btn:hover {
  background: var(--border);
}

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

/* Loading pulse */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.card.loading .badge.loading {
  animation: pulse 1.4s ease-in-out infinite;
}
