:root {
  --bg: #ffffff;
  --text: #0c1724;
  --text-muted: #475569;
  --surface: #f7f9fc;
  --surface-border: #e6eef9;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --btn-bg: #ffffff;
  --btn-border: #dbeafd;
  --btn-text: #0c1724;
  --input-bg: #ffffff;
  --input-border: #d0e6ff;
  --toggle-bg: rgba(255, 255, 255, 0.94);
  --toggle-border: #d1ddec;
  --toggle-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
  --bg: #09111f;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --surface: #111b2e;
  --surface-border: #25324a;
  --card-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  --btn-bg: #0f1a2e;
  --btn-border: #2a3a5a;
  --btn-text: #e2e8f0;
  --input-bg: #0c1629;
  --input-border: #2d3f61;
  --toggle-bg: rgba(10, 17, 31, 0.94);
  --toggle-border: #32476d;
  --toggle-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

html,body{font-family:'Ubuntu',system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif}
body{margin:0;background:var(--bg);color:var(--text);padding:20px;transition:background-color .2s ease,color .2s ease}
.wrap{max-width:820px;margin:0 auto}
.card{background:var(--surface);padding:18px;border-radius:12px;border:1px solid var(--surface-border);box-shadow:var(--card-shadow)}
.grid{display:grid;gap:10px;margin-top:12px}
.btn{display:inline-flex;align-items:center;justify-content:center;padding:12px;border-radius:10px;text-decoration:none;border:1px solid var(--btn-border);background:var(--btn-bg);color:var(--btn-text)}
.primary{background:#2b67f6;color:#fff;border:1px solid #2b67f6}
.form{display:grid;gap:8px;margin-top:10px}
input{padding:10px;border-radius:8px;border:1px solid var(--input-border);background:var(--input-bg);color:var(--text)}
.muted{color:var(--text-muted)}
.hidden{display:none}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--toggle-border);
  background: var(--toggle-bg);
  color: var(--text);
  box-shadow: var(--toggle-shadow);
  cursor: pointer;
}
.theme-toggle:hover { transform: translateY(-1px); }
.theme-toggle:focus-visible {
  outline: 2px solid #2b67f6;
  outline-offset: 2px;
}
.theme-toggle-icon { font-size: 18px; line-height: 1; }
.theme-toggle .theme-toggle-icon-sun { display: inline; }
.theme-toggle .theme-toggle-icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .theme-toggle-icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-toggle-icon-moon { display: inline; }
input,
button,
select,
textarea {
  font-size: 16px;
}
#build {
    margin-top: 24px;
    margin-right: 12px;
    font-size: 0.9rem;
    text-align: right;
    color: var(--text-muted); /* subtle gray tone */
}
.btn, button {
    min-height: 44px; /* Apple HIG recommends 44x44 touch area */
  }
.calendar-btn {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center;
  padding: 20px !important;
  gap: 6px;
}
.calendar-btn strong,
.calendar-btn span {
  display: block;
  width: 100%;
}
.logo-container {
  text-align: center;
  margin-bottom: 20px;
}
.logo-container a {
  display: inline-block;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
.logo-container a:hover {
  opacity: 0.8;
}
.logo-container img {
  max-width: 120px;
  height: auto;
}
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 20px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--surface-border);
  background: var(--btn-bg);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  box-shadow: var(--card-shadow);
}
.back-button:hover {
  background: var(--surface);
  border-color: var(--btn-border);
  color: #2b67f6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}
.back-button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden {
  display: none;
}
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 1;
}
.modal-content h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.5rem;
}
.modal-content p {
  margin: 12px 0;
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  gap: 10px;
}
@media(min-width:640px){.grid{grid-template-columns:repeat(2,1fr)}}
.disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--surface-border) !important;
  color: var(--text-muted) !important;
  border-color: var(--btn-border) !important;
}
/* Spacing for subscription card after welcome message */
.wrap .welcome-message + .card.subscription-card {
  margin-top: 15px !important;
}
/* Contact message styling */
.contact-message {
  margin-top: 8px;
}
/* Quote styling in welcome message */
.welcome-message p.quote {
  font-style: italic !important;
  padding: 12px 16px !important;
  border-left: 3px solid #2b67f6 !important;
  margin-top: 20px !important;
  margin-bottom: 0 !important;
  color: var(--text-muted) !important;
  background: rgba(43, 103, 246, 0.08) !important;
  border-radius: 0 8px 8px 0 !important;
  font-size: 1.05rem !important;
  display: block !important;
}
/* Welcome message modal popup */
.welcome-modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(4px) !important;
  z-index: 1000 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  opacity: 1 !important;
  transition: opacity 0.3s ease !important;
}
.welcome-modal-overlay.active {
  display: flex !important;
}
.welcome-modal-overlay.hiding {
  opacity: 0 !important;
  pointer-events: none !important;
}
.welcome-message.modal-active {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  max-width: 600px !important;
  width: calc(100% - 40px) !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  z-index: 1001 !important;
  margin: 0 !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}
body.modal-open {
  overflow: hidden !important;
}
/* Welcome details expandable section */
.welcome-details {
  margin-top: 16px;
}
.welcome-details summary {
  cursor: pointer;
  font-weight: 500;
  color: #2b67f6;
  user-select: none;
  padding: 8px 0;
  list-style: none;
}
.welcome-details summary::-webkit-details-marker {
  display: none;
}
.welcome-details summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.2s;
  font-size: 0.8em;
}
.welcome-details[open] summary::before {
  transform: rotate(90deg);
}
.welcome-details-content {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e6eef9;
}
.welcome-details-content p {
  margin: 0 0 16px 0;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}
.welcome-details-content p:last-child {
  margin-bottom: 0;
}
/* Help section styles */
.help-section {
  margin-top: 16px;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0;
}
.help-section summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  list-style: none;
  user-select: none;
}
.help-section summary::-webkit-details-marker {
  display: none;
}
.help-section summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s;
  color: #475569;
}
.help-section[open] summary::before {
  transform: rotate(90deg);
}
.help-content {
  padding: 0 18px 18px 18px;
  border-top: 1px solid var(--surface-border);
  margin-top: 0;
}
.help-subsection {
  margin-top: 20px;
}
.help-subsection:first-child {
  margin-top: 18px;
}
.help-subsection h3 {
  margin: 0 0 12px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.help-subsection ol {
  margin: 12px 0;
  padding-left: 24px;
}
.help-subsection li {
  margin: 6px 0;
  line-height: 1.6;
  color: var(--text);
}
.help-subsection p {
  margin: 12px 0;
  line-height: 1.6;
  color: var(--text);
}
.ics-url-container {
  margin: 16px 0;
}
.ics-url-container pre {
  margin: 0 0 10px 0;
  padding: 12px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.875rem;
}
.ics-url-container code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--text);
  word-break: break-all;
  white-space: pre-wrap;
}
.ics-url-container .btn {
  width: 100%;
  margin-top: 8px;
}
.help-tip {
  margin-top: 12px !important;
  font-size: 0.9rem;
  color: #475569 !important;
  font-style: italic;
}
@media (max-width: 640px) {
  .welcome-modal-overlay {
    padding: 10px !important;
  }
  .welcome-message.modal-active {
    max-height: 95vh !important;
  }
}
