:root {
  --base-font-size: 1rem;
  --aws-orange: #ff9900;
  --aws-dark-blue: #232f3e;
  --aws-light-blue: #146eb4;
  --aws-squid-ink: #16191f;
  --aws-gray-100: #f2f3f3;
  --aws-gray-200: #eaeded;
  --aws-gray-300: #d5dbdb;
  --aws-gray-600: #687078;
  --border-radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  font-family: "Amazon Ember", "Noto Sans", Arial, sans-serif;
  line-height: 1.6;
  box-sizing: border-box;
}

body {
  background: var(--aws-gray-100);
  color: var(--aws-dark-blue);
}

/* Accessibility: Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Accessibility: Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--aws-orange);
  outline-offset: 2px;
}

header {
  background: linear-gradient(135deg, var(--aws-squid-ink) 0%, var(--aws-dark-blue) 100%);
  position: relative;
  overflow: hidden;
}

header h1 {
  color: #fff;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 300;
  text-align: center;
  padding: 2rem 0;
  margin: 0;
}

.container {
  display: flex;
  max-width: 72rem;
  margin: -2rem auto 0;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: calc(100vh - 200px);
  position: relative;
  z-index: 2;
}

.left-panel {
  flex: 1;
  background: #fff;
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  overflow-y: auto;
}

.right-panel {
  flex: 1;
  background: #fff;
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  overflow-y: auto;
}

.category {
  margin-bottom: 2rem;
}

.category h3 {
  color: var(--aws-dark-blue);
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--aws-gray-200);
}

.question-list {
  list-style: none;
  padding: 0;
}

.question-list li {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.question-list a {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: var(--aws-dark-blue);
  background: var(--aws-gray-100);
  border-radius: calc(var(--border-radius) / 2);
  transition: var(--transition);
  border-left: 4px solid transparent;
  font-size: 0.875rem;
}

.question-number {
  font-weight: 600;
  color: var(--aws-dark-blue);
  min-width: 20px;
  flex-shrink: 0;
}

.question-text {
  flex: 1;
}

.question-list a:hover {
  background: #fff9f0;
  border-left-color: var(--aws-orange);
  transform: translateX(5px);
  color: var(--aws-light-blue);
}

.question-list a.active {
  background: var(--aws-light-blue);
  color: #fff;
  border-left-color: var(--aws-orange);
}

.full-page-link {
  float: right;
  color: var(--aws-light-blue);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: calc(var(--border-radius) / 2);
  transition: var(--transition);
}

.full-page-link:hover {
  background: var(--aws-orange);
  color: #fff;
}

.level5 {
  background: linear-gradient(135deg, #e8f4fd 0%, #d1e7f7 100%);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin: 2rem 0;
  border-left: 4px solid var(--aws-light-blue);
}

.level5 h3 {
  color: var(--aws-dark-blue);
  margin-bottom: 1rem;
}

.level5 p {
  color: var(--aws-dark-blue);
  font-style: italic;
}

.anecdote {
  background: linear-gradient(135deg, #fff9f0 0%, #fff4e4 100%);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin: 2rem 0;
  border-left: 4px solid var(--aws-orange);
}

.anecdote h3 {
  color: var(--aws-dark-blue);
  margin-bottom: 1rem;
}

#question-detail {
  min-height: 300px;
}

#question-detail h2 {
  color: var(--aws-dark-blue);
  margin-bottom: 1rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 400;
}

#question-detail h3 {
  color: var(--aws-light-blue);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 1.5rem 0 1rem 0;
}

#question-detail p {
  color: var(--aws-dark-blue);
  font-size: var(--base-font-size);
  margin-bottom: 1rem;
  line-height: 1.6;
}

#question-detail ul {
  padding: 0 0 0 1.4rem;
  margin-bottom: 1rem;
}

#question-detail li {
  color: var(--aws-dark-blue);
  padding-left: 0.5rem;
  margin: 0.2rem 0;
}

.question-meta {
  background: linear-gradient(135deg, #fff9f0 0%, #fff4e4 100%);
  padding: 1rem;
  border-radius: calc(var(--border-radius) / 2);
  margin: 1rem 0;
  border-left: 4px solid var(--aws-orange);
}

.question-meta strong {
  color: var(--aws-dark-blue);
  font-weight: bold;
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
    height: auto;
    padding: 0 1rem;
    margin-top: -1rem;
  }
  
  header h1 {
    font-size: 1.6rem;
    padding: 1.5rem 0;
  }
  
  .left-panel,
  .right-panel {
    padding: 1.25rem;
  }
}

/* Authentication Styles */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--aws-squid-ink) 0%, var(--aws-dark-blue) 100%);
  padding: 2rem;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.auth-message {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 3rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 500px;
  width: 100%;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-message h2 {
  color: var(--aws-dark-blue);
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  font-weight: 400;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.auth-message p {
  color: var(--aws-gray-600);
  font-size: clamp(0.9rem, 2vw, 1rem);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.aws-button {
  background: var(--aws-orange);
  color: #fff;
  border: none;
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: calc(var(--border-radius) / 2);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  min-width: 200px;
  position: relative;
  overflow: hidden;
}

.aws-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.aws-button:hover::before {
  width: 300px;
  height: 300px;
}

.aws-button:hover {
  background: #ec7211;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 153, 0, 0.4);
}

.aws-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.aws-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.3);
}

.aws-button:disabled {
  background: var(--aws-gray-300);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auth-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--aws-squid-ink) 0%, var(--aws-dark-blue) 100%);
  padding: 2rem;
  animation: fadeIn 0.3s ease-in;
}

.auth-error > div {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 3rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 500px;
  width: 100%;
  border-top: 4px solid #d13212;
  animation: slideUp 0.4s ease-out;
}

.auth-error h2 {
  color: #d13212;
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  font-weight: 400;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.auth-error p {
  color: var(--aws-gray-600);
  font-size: clamp(0.9rem, 2vw, 1rem);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* User Info Display */
.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #fff;
  animation: fadeIn 0.3s ease-in;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.sign-out-button {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: calc(var(--border-radius) / 2);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.sign-out-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.sign-out-button:active {
  transform: translateY(0);
}

.sign-out-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 153, 0, 0.3);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.tone-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: fadeIn 0.3s ease-in;
}

.tone-selector label {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 400;
  white-space: nowrap;
}

.tone-dropdown {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: calc(var(--border-radius) / 2);
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  min-width: 120px;
}

.tone-dropdown:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.tone-dropdown:focus {
  outline: none;
  border-color: var(--aws-orange);
  box-shadow: 0 0 0 2px rgba(255, 153, 0, 0.3);
  background: rgba(255, 255, 255, 0.15);
}

.tone-dropdown:active {
  transform: translateY(0);
}

.tone-dropdown option {
  background: var(--aws-dark-blue);
  color: #fff;
  padding: 0.5rem;
  font-size: 0.875rem;
}

/* Accessibility: High contrast mode support */
@media (prefers-contrast: high) {
  .tone-dropdown {
    border-width: 2px;
    border-color: #fff;
  }
  
  .tone-dropdown:focus {
    border-color: var(--aws-orange);
    box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.5);
  }
}

/* Accessibility: Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .tone-dropdown {
    transition: none;
  }
  
  .tone-dropdown:hover {
    transform: none;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 1rem;
  }

  .header-right {
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    align-items: stretch;
  }

  .tone-selector {
    flex-direction: row;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
  }
  
  .tone-selector label {
    font-size: 0.8rem;
  }

  .tone-dropdown {
    width: auto;
    flex: 1;
    max-width: 200px;
    min-width: 140px;
  }

  .user-info {
    flex-direction: row;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
  }
  
  .user-name {
    max-width: 150px;
    font-size: 0.8rem;
  }
  
  .sign-out-button {
    font-size: 0.8rem;
    padding: 0.4rem 0.875rem;
  }

  .auth-message,
  .auth-error > div {
    padding: 2rem 1.5rem;
    margin: 1rem;
  }
  
  .auth-message h2,
  .auth-error h2 {
    font-size: 1.5rem;
  }
  
  .auth-message p,
  .auth-error p {
    font-size: 0.9rem;
  }
  
  .aws-button {
    width: 100%;
    min-width: auto;
    padding: 0.875rem 1.5rem;
  }
  
  .loading-content,
  .error-content {
    padding: 2rem 1.5rem;
    margin: 1rem;
  }
}

/* Tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 90%;
    gap: 1rem;
  }
  
  .header-content {
    padding: 0 1rem;
  }
  
  .tone-dropdown {
    min-width: 110px;
  }
  
  .user-name {
    max-width: 150px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .header-content {
    padding: 0.75rem;
  }
  
  header h1 {
    font-size: 1.4rem;
    padding: 1rem 0;
  }
  
  .tone-selector {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  
  .tone-selector label {
    font-size: 0.75rem;
  }
  
  .tone-dropdown {
    width: 100%;
    max-width: 100%;
    min-width: auto;
  }
  
  .user-info {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }
  
  .user-name {
    max-width: 100%;
    text-align: center;
  }
  
  .sign-out-button {
    width: 100%;
    max-width: 200px;
  }
  
  .container {
    padding: 0 0.75rem;
    gap: 1rem;
  }
  
  .left-panel,
  .right-panel {
    padding: 1rem;
  }
  
  .auth-message,
  .auth-error > div {
    padding: 1.5rem 1rem;
  }
  
  .category h3 {
    font-size: 1.1rem;
  }
  
  .question-list a {
    padding: 0.7rem 0.875rem;
    font-size: 0.8rem;
  }
  
  #question-detail h2 {
    font-size: 1.4rem;
  }
  
  #question-detail h3 {
    font-size: 1.1rem;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .container {
    flex-direction: row;
    height: calc(100vh - 180px);
  }
  
  .header-content {
    flex-direction: row;
    justify-content: space-between;
  }
  
  .header-right {
    flex-direction: row;
    width: auto;
    gap: 1.5rem;
  }
  
  .tone-selector {
    flex-direction: row;
  }
  
  .user-info {
    flex-direction: row;
  }
}

/* Loading and Error States */
.loading-state {
  text-align: center;
  padding: 3rem 2rem;
}

.loading-state h2 {
  color: var(--aws-dark-blue);
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

.loading-state p {
  color: var(--aws-gray-600);
  font-size: 1rem;
}

.api-error {
  text-align: center;
  padding: 3rem 2rem;
  background: linear-gradient(135deg, #fff9f0 0%, #fff4e4 100%);
  border-radius: var(--border-radius);
  border-left: 4px solid #d13212;
}

.api-error h2 {
  color: #d13212;
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

.api-error p {
  color: var(--aws-gray-600);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.api-error .aws-button {
  margin-top: 1rem;
}

/* Loading Indicator Overlay */
.loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(35, 47, 62, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 3rem;
  box-shadow: var(--shadow-md);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 1.5rem;
  border: 4px solid var(--aws-gray-200);
  border-top-color: var(--aws-orange);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-content p {
  color: var(--aws-dark-blue);
  font-size: 1rem;
  font-weight: 400;
  margin: 0;
}

/* Initialization Error */
.init-error {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--aws-squid-ink) 0%, var(--aws-dark-blue) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 2rem;
}

.error-content {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 3rem;
  box-shadow: var(--shadow-md);
  text-align: center;
  max-width: 500px;
  width: 100%;
  border-top: 4px solid #d13212;
}

.error-content h2 {
  color: #d13212;
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

.error-content p {
  color: var(--aws-gray-600);
  font-size: 1rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.error-content .aws-button {
  margin-top: 1rem;
}